Image coding method based on quadratic transform, and apparatus therefor

ABSTRACT

An image decoding method according to the present document comprises the steps of: receiving a quantized transform coefficient for a target block and a transform index for non-separable quadratic transform; deriving transform coefficients by inversely quantizing the quantized transform coefficient; deriving corrected transform coefficients on the basis of a transform kernel matrix in a predetermined transform set indicated by the transform index; and deriving residual samples for the target block on the basis of inverse linear transform for the corrected transform coefficients, wherein when the target block is divided into a predetermined number of sub-blocks and is coded by intra prediction, the corrected transform coefficients are derived in units of the sub-blocks, and the transform index is received for the target block.

This application is a Bypass Continuation of International Application No. PCT/KR2020/002625, filed on Feb. 24, 2020, which claims the benefit of U.S. Provisional Application No. 62/809,721, filed Feb. 24, 2019, the disclosures of which are incorporated herein by reference in their entirety.

TECHNICAL FIELD

The present disclosure relates generally to an image coding technology and, more particularly, to an image coding method based on a transform in an image coding system and an apparatus therefor.

RELATED ART

Nowadays, the demand for high-resolution and high-quality images/videos such as 4K, 8K or more ultra high definition (UHD) images/videos has been increasing in various fields. As the image/video data becomes higher resolution and higher quality, the transmitted information amount or bit amount increases as compared to the conventional image data. Therefore, when image data is transmitted using a medium such as a conventional wired/wireless broadband line or image/video data is stored using an existing storage medium, the transmission cost and the storage cost thereof are increased.

Further, nowadays, the interest and demand for immersive media such as virtual reality (VR), artificial reality (AR) content or hologram, or the like is increasing, and broadcasting for images/videos having image features different from those of real images, such as a game image is increasing.

Accordingly, there is a need for a highly efficient image/video compression technique for effectively compressing and transmitting or storing, and reproducing information of high resolution and high quality images/videos having various features as described above.

SUMMARY

A technical aspect of the present disclosure is to provide a method and an apparatus for increasing image coding efficiency.

Another technical aspect of the present disclosure is to provide a method and an apparatus for increasing transform efficiency.

Still another technical aspect of the present disclosure is to provide an image transform method and an image transform apparatus for applied to a partitioned subblock.

Yet another technical aspect of the present disclosure is to provide a method and an apparatus for increasing the efficiency of a secondary transform by changing the array of transform coefficients according to an intra prediction mode.

Still another technical aspect of the present disclosure is to provide an image coding method and an image coding apparatus for increasing the efficiency of a secondary transform by optimizing the transformation kernel matrix applied to the secondary transform.

Still another technical aspect of the present disclosure is to provide an image coding method and an image coding apparatus which are based on a transform set for increasing coding efficiency.

According to an embodiment of the present disclosure, there is provided an image decoding method performed by a decoding apparatus. The method may include: receiving quantized transform coefficients for a target block and a transform index for a non-separable secondary transform; deriving transform coefficients by dequantizing the quantized transform coefficients; deriving modified transform coefficients based on a transform kernel matrix in a predetermined transform set indicated by the transform index; and deriving residual samples for the target block based on an inverse primary transform of the modified transform coefficients, wherein when the target block is partitioned into a predetermined number of subblocks and is coded by intra prediction, the modified transform coefficients may be derived by a unit of a subblock, and wherein the transform index may be received with respect to the target block.

The same transform kernel matrix may be applied to the subblocks in the non-separable secondary transform.

The target block may be a coding unit, and the subblocks may be transform units.

The target block may be vertically partitioned when the target block has a size (width×height) of 8×4, and the target block may be horizontally partitioned when the target block has a size (width×height) of 4×8.

A block A being greater than another block B may mean that the horizontal length and the vertical length of A are equal to or greater than the horizontal length and the vertical length of B, respectively, and the horizontal length of A is greater than the horizontal length of B or the vertical length of A is greater than the vertical length of B. For example, the size (width×height) of the target block being greater than 4×8 or 8×4 may include 1) a case where the size of the target block is 4×N or N×4 (N≥16) or 2) a case where the size of the target block is M×N (M≥8, N≥8). In this case, the target block may be horizontally or vertically partitioned into four subblocks.

According to another embodiment of the present disclosure, there is provided an image encoding method performed by an encoding apparatus. The method may include: deriving prediction samples based on an intra prediction mode applied to a target block; deriving residual samples for the target block based on the prediction samples; deriving transform coefficients by applying a primary transform to the residual samples; deriving modified transform coefficients by performing a non-separable secondary transform on the transform coefficients using a transform set mapped to the intra prediction mode of the target block and one transform kernel matrix included in the transform set; deriving quantized transform coefficients by performing quantization based on the modified transform coefficients; and encoding a transform index indicating the transform kernel matrix and the quantized transform coefficients, wherein when the target block is a coding block that is partitioned into a predetermined number of subblocks and is subjected to intra prediction, the modified transform coefficients may be derived by a unit of a subblock, and wherein the same transform kernel matrix may be applied to the subblocks in the non-separable secondary transform.

According to still another embodiment of the present disclosure, there may be provided a digital storage medium that stores image data including encoded image information and a bitstream generated according to an image encoding method performed by an encoding apparatus.

According to yet another embodiment of the present disclosure, there may be provided a digital storage medium that stores image data including encoded image information and a bitstream to cause a decoding apparatus to perform the image decoding method.

According to the present disclosure, it is possible to increase overall image/video compression efficiency.

According to the present disclosure, it is possible to increase the efficiency of a secondary transform by changing the array of transform coefficients according to an intra prediction mode.

According to the present disclosure, it is possible to increase image coding efficiency by applying a non-separable secondary transform to a partitioned subblock.

According to the present disclosure, it is possible to increase the efficiency of a secondary transform by optimizing the transformation kernel matrix applied to the secondary transform.

The effects that can be obtained through specific examples of the present disclosure are not limited to the effects listed above. For example, there may be various technical effects that a person having ordinary skill in the related art can understand or derive from the present disclosure. Accordingly, specific effects of the present disclosure are not limited to those explicitly described in the present disclosure and may include various effects that can be understood or derived from the technical features of the present disclosure.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 schematically illustrates an example of a video/image coding system to which the present disclosure is applicable.

FIG. 2 is a diagram schematically illustrating a configuration of a video/image encoding apparatus to which the present disclosure is applicable.

FIG. 3 is a diagram schematically illustrating a configuration of a video/image decoding apparatus to which the present disclosure is applicable.

FIG. 4 schematically illustrates a multiple transform technique according to an embodiment of the present disclosure.

FIG. 5 illustrates directional intra modes of 65 prediction directions.

FIG. 6 is a diagram illustrating an RST according to an embodiment of the present disclosure.

FIG. 7 is a diagram illustrating a transform coefficient scanning order according to an embodiment of the present disclosure.

FIG. 8 is a flowchart illustrating an inverse RST process according to an embodiment of the present disclosure.

FIG. 9 illustrates an example in which one coding block is partitioned into subblocks.

FIG. 10 illustrates another example in which one coding block is partitioned into subblocks.

FIG. 11 is a flowchart illustrating an operation of a video decoding apparatus according to an embodiment of the present disclosure.

FIG. 12 is a control flowchart illustrating an image decoding method by a decoding apparatus according to an embodiment of the present disclosure.

FIG. 13 is a flowchart illustrating an operation of a video encoding apparatus according to an embodiment of the present disclosure.

FIG. 14 is a control flowchart illustrating an image encoding method by an encoding apparatus according to an embodiment of the present disclosure.

FIG. 15 illustrates the structure of a content streaming system to which the present disclosure is applied.

DESCRIPTION OF EXEMPLARY EMBODIMENTS

While the present disclosure may be susceptible to various modifications and include various embodiments, specific embodiments thereof have been shown in the drawings by way of example and will now be described in detail. However, this is not intended to limit the present disclosure to the specific embodiments disclosed herein. The terminology used herein is for the purpose of describing specific embodiments only, and is not intended to limit technical idea of the present disclosure. The singular forms may include the plural forms unless the context clearly indicates otherwise. The terms such as “include” and “have” are intended to indicate that features, numbers, steps, operations, elements, components, or combinations thereof used in the following description exist, and thus should not be understood as that the possibility of existence or addition of one or more different features, numbers, steps, operations, elements, components, or combinations thereof is excluded in advance.

Meanwhile, each component on the drawings described herein is illustrated independently for convenience of description as to characteristic functions different from each other, and however, it is not meant that each component is realized by a separate hardware or software. For example, any two or more of these components may be combined to form a single component, and any single component may be divided into plural components. The embodiments in which components are combined and/or divided will belong to the scope of the patent right of the present disclosure as long as they do not depart from the essence of the present disclosure.

Hereinafter, preferred embodiments of the present disclosure will be explained in more detail while referring to the attached drawings. In addition, the same reference signs are used for the same components on the drawings, and repeated descriptions for the same components will be omitted.

This document relates to video/image coding. For example, the method/example disclosed in this document may relate to a VVC (Versatile Video Coding) standard (ITU-T Rec. H.266), a next-generation video/image coding standard after VVC, or other video coding related standards (e.g., HEVC (High Efficiency Video Coding) standard (ITU-T Rec. H.265), EVC (essential video coding) standard, AVS2 standard, etc.).

In this document, a variety of embodiments relating to video/image coding may be provided, and, unless specified to the contrary, the embodiments may be combined to each other and be performed.

In this document, a video may mean a set of a series of images over time. Generally a picture means a unit representing an image at a specific time zone, and a slice/tile is a unit constituting a part of the picture. The slice/tile may include one or more coding tree units (CTUs). One picture may be constituted by one or more slices/tiles. One picture may be constituted by one or more tile groups. One tile group may include one or more tiles.

A pixel or a pel may mean a smallest unit constituting one picture (or image). Also, ‘sample’ may be used as a term corresponding to a pixel. A sample may generally represent a pixel or a value of a pixel, and may represent only a pixel/pixel value of a luma component or only a pixel/pixel value of a chroma component. Alternatively, the sample may refer to a pixel value in the spatial domain, or when this pixel value is converted to the frequency domain, it may refer to a transform coefficient in the frequency domain.

A unit may represent the basic unit of image processing. The unit may include at least one of a specific region and information related to the region. One unit may include one luma block and two chroma (e.g., cb and cr) blocks. The unit and a term such as a block, an region, or the like may be used in place of each other according to circumstances. In a general case, an M×N block may include a set (or an array) of samples (or sample arrays) or transform coefficients consisting of M columns and N rows.

In this document, the term “/” and “,” should be interpreted to indicate “and/or.” For instance, the expression “A/B” may mean “A and/or B.” Further, “A, B” may mean “A and/or B.” Further, “A/B/C” may mean “at least one of A, B, and/or C.” Also, “A/B/C” may mean “at least one of A, B, and/or C.”

Further, in the document, the term “or” should be interpreted to indicate “and/or.” For instance, the expression “A or B” may include 1) only A, 2) only B, and/or 3) both A and B. In other words, the term “or” in this document should be interpreted to indicate “additionally or alternatively.”

In the present disclosure, “at least one of A and B” may mean “only A”, “only B”, or “both A and B”. In addition, in the present disclosure, the expression “at least one of A or B” or “at least one of A and/or B” may be interpreted as “at least one of A and B”.

In addition, in the present disclosure, “at least one of A, B, and C” may mean “only A”, “only B”, “only C”, or “any combination of A, B, and C”. In addition, “at least one of A, B, or C” or “at least one of A, B, and/or C” may mean “at least one of A, B, and C”.

In addition, a parenthesis used in the present disclosure may mean “for example”. Specifically, when indicated as “prediction (intra prediction)”, it may mean that “intra prediction” is proposed as an example of “prediction”. That is, “prediction” in the present disclosure is not limited to “intra prediction”, and “intra prediction” may be proposed as an example of “prediction”. In addition, when indicated as “prediction (i.e., intra prediction)”, it may also mean that “intra prediction” is proposed as an example of “prediction”.

Technical features individually described in one figure in the present disclosure may be individually implemented or may be simultaneously implemented.

FIG. 1 schematically illustrates an example of a video/image coding system to which the present disclosure is applicable.

Referring to FIG. 1, the video/image coding system may include a first device (source device) and a second device (receive device). The source device may deliver encoded video/image information or data in the form of a file or streaming to the receive device via a digital storage medium or network.

The source device may include a video source, an encoding apparatus, and a transmitter. The receive device may include a receiver, a decoding apparatus, and a renderer. The encoding apparatus may be called a video/image encoding apparatus, and the decoding apparatus may be called a video/image decoding apparatus. The transmitter may be included in the encoding apparatus. The receiver may be included in the decoding apparatus. The renderer may include a display, and the display may be configured as a separate device or an external component.

The video source may obtain a video/image through a process of capturing, synthesizing, or generating a video/image. The video source may include a video/image capture device and/or a video/image generating device. The video/image capture device may include, for example, one or more cameras, video/image archives including previously captured video/images, or the like. The video/image generating device may include, for example, a computer, a tablet and a smartphone, and may (electronically) generate a video/image. For example, a virtual video/image may be generated through a computer or the like. In this case, the video/image capturing process may be replaced by a process of generating related data.

The encoding apparatus may encode an input video/image. The encoding apparatus may perform a series of procedures such as prediction, transform, and quantization for compression and coding efficiency. The encoded data (encoded video/image information) may be output in the form of a bitstream.

The transmitter may transmit the encoded video/image information or data output in the form of a bitstream to the receiver of the receive device through a digital storage medium or a network in the form of a file or streaming. The digital storage medium may include various storage mediums such as USB, SD, CD, DVD, Blu-ray, HDD, SSD, and the like. The transmitter may include an element for generating a media file through a predetermined file format, and may include an element for transmission through a broadcast/communication network. The receiver may receive/extract the bitstream and transmit the received/extracted bitstream to the decoding apparatus.

The decoding apparatus may decode a video/image by performing a series of procedures such as dequantization, inverse transform, prediction, and the like corresponding to the operation of the encoding apparatus.

The renderer may render the decoded video/image. The rendered video/image may be displayed through the display.

FIG. 2 is a diagram schematically illustrating a configuration of a video/image encoding apparatus to which the present disclosure is applicable. Hereinafter, what is referred to as the video encoding apparatus may include an image encoding apparatus.

Referring to FIG. 2, the encoding apparatus 200 may include an image partitioner 210, a predictor 220, a residual processor 230, an entropy encoder 240, an adder 250, a filter 260, and a memory 270. The predictor 220 may include an inter predictor 221 and an intra predictor 222. The residual processor 230 may include a transformer 232, a quantizer 233, a dequantizer 234, an inverse transformer 235. The residual processor 230 may further include a subtractor 231. The adder 250 may be called a reconstructor or a reconstructed block generator. The image partitioner 210, the predictor 220, the residual processor 230, the entropy encoder 240, the adder 250, and the filter 260, which have been described above, may be constituted by one or more hardware components (e.g., encoder chipsets or processors) according to an embodiment. Further, the memory 270 may include a decoded picture buffer (DPB), and may be constituted by a digital storage medium. The hardware component may further include the memory 270 as an internal/external component.

The image partitioner 210 may partition an input image (or a picture or a frame) input to the encoding apparatus 200 into one or more processing units. As one example, the processing unit may be called a coding unit (CU). In this case, starting with a coding tree unit (CTU) or the largest coding unit (LCU), the coding unit may be recursively partitioned according to the Quad-tree binary-tree ternary-tree (QTBTTT) structure. For example, one coding unit may be divided into a plurality of coding units of a deeper depth based on the quad-tree structure, the binary-tree structure, and/or the ternary structure. In this case, for example, the quad-tree structure may be applied first and the binary-tree structure and/or the ternary structure may be applied later. Alternatively, the binary-tree structure may be applied first. The coding procedure according to the present disclosure may be performed based on the final coding unit which is not further partitioned. In this case, the maximum coding unit may be used directly as a final coding unit based on coding efficiency according to the image characteristic. Alternatively, the coding unit may be recursively partitioned into coding units of a further deeper depth as needed, so that the coding unit of an optimal size may be used as a final coding unit. Here, the coding procedure may include procedures such as prediction, transform, and reconstruction, which will be described later. As another example, the processing unit may further include a prediction unit (PU) or a transform unit (TU). In this case, the prediction unit and the transform unit may be split or partitioned from the above-described final coding unit. The prediction unit may be a unit of sample prediction, and the transform unit may be a unit for deriving a transform coefficient and/or a unit for deriving a residual signal from a transform coefficient.

The unit and a term such as a block, an region, or the like may be used in place of each other according to circumstances. In a general case, an M×N block may represent a set of samples or transform coefficients consisting of M columns and N rows. The sample may generally represent a pixel or a value of a pixel, and may represent only a pixel/pixel value of a luma component, or only a pixel/pixel value of a chroma component. The sample may be used as a term corresponding to a pixel or a pa of one picture (or image).

The subtractor 231 subtracts a prediction signal (predicted block, prediction sample array) output from the inter predictor 221 or the intra predictor 222 from an input image signal (original block, original sample array) to generate a residual signal (residual block, residual sample array), and the generated residual signal is transmitted to the transformer 232. In this case, as shown, a unit which subtracts the prediction signal (predicted block, prediction sample array) from the input image signal (original block, original sample array) in the encoder 200 may be called the subtractor 231. The predictor may perform prediction on a processing target block (hereinafter, referred to as ‘current block’), and may generate a predicted block including prediction samples for the current block. The predictor may determine whether intra prediction or inter prediction is applied on a current block or CU basis. As discussed later in the description of each prediction mode, the predictor may generate various pieces of information relating to prediction, such as prediction mode information, and transmit the generated information to the entropy encoder 240. The information on the prediction may be encoded in the entropy encoder 240 and output in the form of a bitstream.

The intra predictor 222 may predict the current block by referring to samples in the current picture. The referred samples may be located in the neighbor of or apart from the current block according to the prediction mode. In the intra prediction, prediction modes may include a plurality of non-directional modes and a plurality of directional modes. The non-directional modes may include, for example, a DC mode and a planar mode. The directional mode may include, for example, 33 directional prediction modes or 65 directional prediction modes according to the degree of detail of the prediction direction. However, this is merely an example, and more or less directional prediction modes may be used depending on a setting. The intra predictor 222 may determine the prediction mode applied to the current block by using the prediction mode applied to the neighboring block.

The inter predictor 221 may derive a predicted block for the current block based on a reference block (reference sample array) specified by a motion vector on a reference picture. At this time, in order to reduce the amount of motion information transmitted in the inter prediction mode, the motion information may be predicted on a block, subblock, or sample basis based on correlation of motion information between the neighboring block and the current block. The motion information may include a motion vector and a reference picture index. The motion information may further include inter prediction direction (L0 prediction, L1 prediction, Bi prediction, etc.) information. In the case of inter prediction, the neighboring block may include a spatial neighboring block existing in the current picture and a temporal neighboring block existing in the reference picture. The reference picture including the reference block and the reference picture including the temporal neighboring block may be same to each other or different from each other. The temporal neighboring block may be called a collocated reference block, a collocated CU (colCU), and the like, and the reference picture including the temporal neighboring block may be called a collocated picture (colPic). For example, the inter predictor 221 may configure a motion information candidate list based on neighboring blocks and generate information indicating which candidate is used to derive a motion vector and/or a reference picture index of the current block. Inter prediction may be performed based on various prediction modes. For example, in the case of a skip mode and a merge mode, the inter predictor 221 may use motion information of the neighboring block as motion information of the current block. In the skip mode, unlike the merge mode, the residual signal may not be transmitted. In the case of the motion information prediction (motion vector prediction, MVP) mode, the motion vector of the neighboring block may be used as a motion vector predictor and the motion vector of the current block may be indicated by signaling a motion vector difference.

The predictor 220 may generate a prediction signal based on various prediction methods. For example, the predictor may apply intra prediction or inter prediction for prediction on one block, and, as well, may apply intra prediction and inter prediction at the same time. This may be called combined inter and intra prediction (CIIP). Further, the predictor may be based on an intra block copy (IBC) prediction mode, or a palette mode in order to perform prediction on a block. The IBC prediction mode or palette mode may be used for content image/video coding of a game or the like, such as screen content coding (SCC). Although the IBC basically performs prediction in a current block, it can be performed similarly to inter prediction in that it derives a reference block in a current block. That is, the IBC may use at least one of inter prediction techniques described in the present disclosure.

The prediction signal generated through the inter predictor 221 and/or the intra predictor 222 may be used to generate a reconstructed signal or to generate a residual signal. The transformer 232 may generate transform coefficients by applying a transform technique to the residual signal. For example, the transform technique may include at least one of a discrete cosine transform (DCT), a discrete sine transform (DST), a Karhunen-Loéve transform (KLT), a graph-based transform (GBT), or a conditionally non-linear transform (CNT). Here, the GBT means transform obtained from a graph when relationship information between pixels is represented by the graph. The CNT refers to transform obtained based on a prediction signal generated using all previously reconstructed pixels. In addition, the transform process may be applied to square pixel blocks having the same size or may be applied to blocks having a variable size rather than the square one.

The quantizer 234 may quantize the transform coefficients and transmit them to the entropy encoder 240, and the entropy encoder 240 may encode the quantized signal (information on the quantized transform coefficients) and output the encoded signal in a bitstream. The information on the quantized transform coefficients may be referred to as residual information. The quantizer 233 may rearrange block type quantized transform coefficients into a one-dimensional vector form based on a coefficient scan order, and generate information on the quantized transform coefficients based on the quantized transform coefficients of the one-dimensional vector form. The entropy encoder 240 may perform various encoding methods such as, for example, exponential Golomb, context-adaptive variable length coding (CAVLC), context-adaptive binary arithmetic coding (CABAC), and the like. The entropy encoder 240 may encode information necessary for video/image reconstruction other than quantized transform coefficients (e.g. values of syntax elements, etc.) together or separately. Encoded information (e.g., encoded video/image information) may be transmitted or stored on a unit basis of a network abstraction layer (NAL) in the form of a bitstream. The video/image information may further include information on various parameter sets such as an adaptation parameter set (APS), a picture parameter set (PPS), a sequence parameter set (SPS), a video parameter set (VPS) or the like. Further, the video/image information may further include general constraint information. In the present disclosure, information and/or syntax elements which are transmitted/signaled to the decoding apparatus from the encoding apparatus may be included in video/image information. The video/image information may be encoded through the above-described encoding procedure and included in the bitstream. The bitstream may be transmitted through a network, or stored in a digital storage medium. Here, the network may include a broadcast network, a communication network and/or the like, and the digital storage medium may include various storage media such as USB, SD, CD, DVD, Blu-ray, HDD, SSD, and the like. A transmitter (not shown) which transmits a signal output from the entropy encoder 240 and/or a storage (not shown) which stores it may be configured as an internal/external element of the encoding apparatus 200, or the transmitter may be included in the entropy encoder 240.

Quantized transform coefficients output from the quantizer 233 may be used to generate a prediction signal. For example, by applying dequantization and inverse transform to quantized transform coefficients through the dequantizer 234 and the inverse transformer 235, the residual signal (residual block or residual samples) may be reconstructed. The adder 155 adds the reconstructed residual signal to a prediction signal output from the inter predictor 221 or the intra predictor 222, so that a reconstructed signal (reconstructed picture, reconstructed block, reconstructed sample array) may be generated. When there is no residual for a processing target block as in a case where the skip mode is applied, the predicted block may be used as a reconstructed block. The adder 250 may be called a reconstructor or a reconstructed block generator. The generated reconstructed signal may be used for intra prediction of a next processing target block in the current block, and as described later, may be used for inter prediction of a next picture through filtering.

Meanwhile, in the picture encoding and/or reconstructing process, luma mapping with chroma scaling (LMCS) may be applied.

The filter 260 may improve subjective/objective video quality by applying the filtering to the reconstructed signal. For example, the filter 260 may generate a modified reconstructed picture by applying various filtering methods to the reconstructed picture, and may store the modified reconstructed picture in the memory 270, specifically in the DPB of the memory 270. The various filtering methods may include, for example, deblocking filtering, sample adaptive offset, an adaptive loop filter, a bilateral filter or the like. As discussed later in the description of each filtering method, the filter 260 may generate various pieces of information relating to filtering, and transmit the generated information to the entropy encoder 240. The information on the filtering may be encoded in the entropy encoder 240 and output in the form of a bitstream.

The modified reconstructed picture which has been transmitted to the memory 270 may be used as a reference picture in the inter predictor 221. Through this, the encoding apparatus can avoid prediction mismatch in the encoding apparatus 100 and a decoding apparatus when the inter prediction is applied, and can also improve coding efficiency.

The DPB of the memory 270 may store the modified reconstructed picture in order to use it as a reference picture in the inter predictor 221. The memory 270 may store motion information of a block in the current picture, from which motion information has been derived (or encoded) and/or motion information of blocks in an already reconstructed picture. The stored motion information may be transmitted to the inter predictor 221 to be utilized as motion information of a neighboring block or motion information of a temporal neighboring block. The memory 270 may store reconstructed samples of reconstructed blocks in the current picture, and transmit them to the intra predictor 222.

FIG. 3 is a diagram schematically illustrating a configuration of a video/image decoding apparatus to which the present disclosure is applicable.

Referring to FIG. 3, the video decoding apparatus 300 may include an entropy decoder 310, a residual processor 320, a predictor 330, an adder 340, a filter 350 and a memory 360. The predictor 330 may include an inter predictor 331 and an intra predictor 332. The residual processor 320 may include a dequantizer 321 and an inverse transformer 321. The entropy decoder 310, the residual processor 320, the predictor 330, the adder 340, and the filter 350, which have been described above, may be constituted by one or more hardware components (e.g., decoder chipsets or processors) according to an embodiment. Further, the memory 360 may include a decoded picture buffer (DPB), and may be constituted by a digital storage medium. The hardware component may further include the memory 360 as an internal/external component.

When a bitstream including video/image information is input, the decoding apparatus 300 may reconstruct an image correspondingly to a process by which video/image information has been processed in the encoding apparatus of FIG. 2. For example, the decoding apparatus 300 may derive units/blocks based on information relating to block partition obtained from the bitstream. The decoding apparatus 300 may perform decoding by using a processing unit applied in the encoding apparatus. Therefore, the processing unit of decoding may be, for example, a coding unit, which may be partitioned along the quad-tree structure, the binary-tree structure, and/or the ternary-tree structure from a coding tree unit or a largest coding unit. One or more transform units may be derived from the coding unit. And, the reconstructed image signal decoded and output through the decoding apparatus 300 may be reproduced through a reproducer.

The decoding apparatus 300 may receive a signal output from the encoding apparatus of FIG. 2 in the form of a bitstream, and the received signal may be decoded through the entropy decoder 310. For example, the entropy decoder 310 may parse the bitstream to derive information (e.g., video/image information) required for image reconstruction (or picture reconstruction). The video/image information may further include information on various parameter sets such as an adaptation parameter set (APS), a picture parameter set (PPS), a sequence parameter set (SPS), a video parameter set (VPS) or the like. Further, the video/image information may further include general constraint information. The decoding apparatus may decode a picture further based on information on the parameter set and/or the general constraint information. In the present disclosure, signaled/received information and/or syntax elements, which will be described later, may be decoded through the decoding procedure and be obtained from the bitstream. For example, the entropy decoder 310 may decode information in the bitstream based on a coding method such as exponential Golomb encoding, CAVLC, CABAC, or the like, and may output a value of a syntax element necessary for image reconstruction and quantized values of a transform coefficient regarding a residual. More specifically, a CABAC entropy decoding method may receive a bin corresponding to each syntax element in a bitstream, determine a context model using decoding target syntax element information and decoding information of neighboring and decoding target blocks, or information of symbol/bin decoded in a previous step, predict bin generation probability according to the determined context model and perform arithmetic decoding of the bin to generate a symbol corresponding to each syntax element value. Here, the CABAC entropy decoding method may update the context model using information of a symbol/bin decoded for a context model of the next symbol/bin after determination of the context model. Information on prediction among information decoded in the entropy decoder 310 may be provided to the predictor (inter predictor 332 and intra predictor 331), and residual values, that is, quantized transform coefficients, on which entropy decoding has been performed in the entropy decoder 310, and associated parameter information may be input to the residual processor 320. The residual processor 320 may derive a residual signal (residual block, residual sample, or residual sample array). Further, information on filtering among information decoded in the entropy decoder 310 may be provided to the filter 350. Meanwhile, a receiver (not shown) which receives a signal output from the encoding apparatus may further constitute the decoding apparatus 300 as an internal/external element, and the receiver may be a component of the entropy decoder 310. Meanwhile, the decoding apparatus according to the present disclosure may be called a video/image/picture coding apparatus, and the decoding apparatus may be classified into an information decoder (video/image/picture information decoder) and a sample decoder (video/image/picture sample decoder). The information decoder may include the entropy decoder 310, and the sample decoder may include at least one of the dequantizer 321, the inverse transformer 322, the adder 340, the filter 350, the memory 360, the inter predictor 332, and the intra predictor 331.

The dequantizer 321 may output transform coefficients by dequantizing the quantized transform coefficients. The dequantizer 321 may rearrange the quantized transform coefficients in the form of a two-dimensional block. In this case, the rearrangement may perform rearrangement based on an order of coefficient scanning which has been performed in the encoding apparatus. The dequantizer 321 may perform dequantization on the quantized transform coefficients using quantization parameter (e.g., quantization step size information), and obtain transform coefficients.

The deqauntizer 322 obtains a residual signal (residual block, residual sample array) by inverse transforming transform coefficients.

The predictor may perform prediction on the current block, and generate a predicted block including prediction samples for the current block. The predictor may determine whether intra prediction or inter prediction is applied to the current block based on the information on prediction output from the entropy decoder 310, and specifically may determine an intra/inter prediction mode.

The predictor may generate a prediction signal based on various prediction methods. For example, the predictor may apply intra prediction or inter prediction for prediction on one block, and, as well, may apply intra prediction and inter prediction at the same time. This may be called combined inter and intra prediction (CIIP). In addition, the predictor may perform intra block copy (IBC) for prediction on a block. The intra block copy may be used for content image/video coding of a game or the like, such as screen content coding (SCC). Although the IBC basically performs prediction in a current block, it can be performed similarly to inter prediction in that it derives a reference block in a current block. That is, the IBC may use at least one of inter prediction techniques described in the present disclosure.

The intra predictor 331 may predict the current block by referring to the samples in the current picture. The referred samples may be located in the neighbor of or apart from the current block according to the prediction mode. In the intra prediction, prediction modes may include a plurality of non-directional modes and a plurality of directional modes. The intra predictor 331 may determine the prediction mode applied to the current block by using the prediction mode applied to the neighboring block.

The inter predictor 332 may derive a predicted block for the current block based on a reference block (reference sample array) specified by a motion vector on a reference picture. At this time, in order to reduce the amount of motion information transmitted in the inter prediction mode, the motion information may be predicted on a block, subblock, or sample basis based on correlation of motion information between the neighboring block and the current block. The motion information may include a motion vector and a reference picture index. The motion information may further include inter prediction direction (L0 prediction, L1 prediction, Bi prediction, etc.) information. In the case of inter prediction, the neighboring block may include a spatial neighboring block existing in the current picture and a temporal neighboring block existing in the reference picture. For example, the inter predictor 332 may configure a motion information candidate list based on neighboring blocks, and derive a motion vector and/or a reference picture index of the current block based on received candidate selection information. Inter prediction may be performed based on various prediction modes, and the information on prediction may include information indicating a mode of inter prediction for the current block.

The adder 340 may generate a reconstructed signal (reconstructed picture, reconstructed block, reconstructed sample array) by adding the obtained residual signal to the prediction signal (predicted block, prediction sample array) output from the predictor 330. When there is no residual for a processing target block as in a case where the skip mode is applied, the predicted block may be used as a reconstructed block.

The adder 340 may be called a reconstructor or a reconstructed block generator. The generated reconstructed signal may be used for intra prediction of a next processing target block in the current block, and as described later, may be output through filtering or be used for inter prediction of a next picture.

Meanwhile, in the picture decoding process, luma mapping with chroma scaling (LMCS) may be applied.

The filter 350 may improve subjective/objective video quality by applying the filtering to the reconstructed signal. For example, the filter 350 may generate a modified reconstructed picture by applying various filtering methods to the reconstructed picture, and may transmit the modified reconstructed picture in the memory 360, specifically in the DPB of the memory 360. The various filtering methods may include, for example, deblocking filtering, sample adaptive offset, an adaptive loop filter, a bilateral filter or the like.

The (modified) reconstructed picture which has been stored in the DPB of the memory 360 may be used as a reference picture in the inter predictor 332. The memory 360 may store motion information of a block in the current picture, from which motion information has been derived (or decoded) and/or motion information of blocks in an already reconstructed picture. The stored motion information may be transmitted to the inter predictor 260 to be utilized as motion information of a neighboring block or motion information of a temporal neighboring block. The memory 360 may store reconstructed samples of reconstructed blocks in the current picture, and transmit them to the intra predictor 331.

In this specification, the examples described in the predictor 330, the dequantizer 321, the inverse transformer 322, and the filter 350 of the decoding apparatus 300 may be similarly or correspondingly applied to the predictor 220, the dequantizer 234, the inverse transformer 235, and the filter 260 of the encoding apparatus 200, respectively.

As described above, prediction is performed in order to increase compression efficiency in performing video coding. Through this, a predicted block including prediction samples for a current block, which is a coding target block, may be generated. Here, the predicted block includes prediction samples in a space domain (or pixel domain). The predicted block may be identically derived in the encoding apparatus and the decoding apparatus, and the encoding apparatus may increase image coding efficiency by signaling to the decoding apparatus not original sample value of an original block itself but information on residual (residual information) between the original block and the predicted block. The decoding apparatus may derive a residual block including residual samples based on the residual information, generate a reconstructed block including reconstructed samples by adding the residual block to the predicted block, and generate a reconstructed picture including reconstructed blocks.

The residual information may be generated through transform and quantization procedures. For example, the encoding apparatus may derive a residual block between the original block and the predicted block, derive transform coefficients by performing a transform procedure on residual samples (residual sample array) included in the residual block, and derive quantized transform coefficients by performing a quantization procedure on the transform coefficients, so that it may signal associated residual information to the decoding apparatus (through a bitstream). Here, the residual information may include value information, position information, a transform technique, transform kernel, a quantization parameter or the like of the quantized transform coefficients. The decoding apparatus may perform a quantization/dequantization procedure and derive the residual samples (or residual sample block), based on residual information. The decoding apparatus may generate a reconstructed block based on a predicted block and the residual block. The encoding apparatus may derive a residual block by dequantizing/inverse transforming quantized transform coefficients for reference for inter prediction of a next picture, and may generate a reconstructed picture based on this.

FIG. 4 schematically illustrates a multiple transform technique according to an embodiment of the present disclosure.

Referring to FIG. 4, a transformer may correspond to the transformer in the encoding apparatus of foregoing FIG. 2, and an inverse transformer may correspond to the inverse transformer in the encoding apparatus of foregoing FIG. 2, or to the inverse transformer in the decoding apparatus of FIG. 3.

The transformer may derive (primary) transform coefficients by performing a primary transform based on residual samples (residual sample array) in a residual block (S410). This primary transform may be referred to as a core transform. Herein, the primary transform may be based on multiple transform selection (MTS), and when a multiple transform is applied as the primary transform, it may be referred to as a multiple core transform.

The multiple core transform may represent a method of transforming additionally using discrete cosine transform (DCT) type 2 and discrete sine transform (DST) type 7, DCT type 8, and/or DST type 1. That is, the multiple core transform may represent a transform method of transforming a residual signal (or residual block) of a space domain into transform coefficients (or primary transform coefficients) of a frequency domain based on a plurality of transform kernels selected from among the DCT type 2, the DST type 7, the DCT type 8 and the DST type 1. Herein, the primary transform coefficients may be called temporary transform coefficients from the viewpoint of the transformer.

In other words, when the conventional transform method is applied, transform coefficients might be generated by applying transform from a space domain to a frequency domain for a residual signal (or residual block) based on the DCT type 2. Unlike to this, when the multiple core transform is applied, transform coefficients (or primary transform coefficients) may be generated by applying transform from a space domain to a frequency domain for a residual signal (or residual block) based on the DCT type 2, the DST type 7, the DCT type 8, and/or DST type 1. Herein, the DCT type 2, the DST type 7, the DCT type 8, and the DST type 1 may be called a transform type, transform kernel or transform core.

For reference, the DCT/DST transform types may be defined based on basis functions, and the basis functions may be represented as in the following table.

TABLE 1 Transform Type Basis function T_(i)(j), i, j = 0, 1, . . . , N-1 DCT-II ${T_{i}(j)} = {\omega_{0} \cdot \sqrt{\frac{2}{N}} \cdot {\cos\left( \frac{\pi \cdot i \cdot \left( {{2j} + 1} \right)}{2N} \right)}}$ ${{where}\mspace{14mu}\omega_{0}} = \left\{ \begin{matrix} \sqrt{\frac{2}{N}} & {i = 0} \\ 1 & {i \neq 0} \end{matrix} \right.$ DCT-V ${{T_{i}(j)} = {\omega_{0} \cdot \omega_{1} \cdot \sqrt{\frac{2}{{2N} - 1}} \cdot {\cos\left( \frac{2{\pi \cdot i \cdot j}}{{2N} - 1} \right)}}},$ ${{where}\mspace{14mu}\omega_{0}} = \left\{ {\begin{matrix} \sqrt{\frac{2}{N}} & {i = 0} \\ 1 & {i \neq 0} \end{matrix},{\omega_{1} = \left\{ \begin{matrix} \sqrt{\frac{2}{N}} & {j = 0} \\ 1 & {j \neq 0} \end{matrix} \right.}} \right.$ DCT-VIII ${T_{i}(j)} = {\sqrt{\frac{4}{{2N} + 1}} \cdot {\cos\left( \frac{\pi \cdot \left( {{2i} + 1} \right) \cdot \left( {{2j} + 1} \right)}{{4N} + 2} \right)}}$ DST-I ${T_{i}(j)} = {\sqrt{\frac{2}{N + 1}} \cdot {\sin\left( \frac{\pi \cdot \left( {i + 1} \right) \cdot \left( {j + 1} \right)}{N + 1} \right)}}$ DST-VII ${T_{i}(j)} = {\sqrt{\frac{4}{{2N} + 1}} \cdot {\sin\left( \frac{\pi \cdot \left( {{2i} + 1} \right) \cdot \left( {j + 1} \right)}{{2N} + 1} \right)}}$

If the multiple core transform is performed, then a vertical transform kernel and a horizontal transform kernel for a target block may be selected from among the transform kernels, a vertical transform for the target block may be performed based on the vertical transform kernel, and a horizontal transform for the target block may be performed based on the horizontal transform kernel. Here, the horizontal transform may represent a transform for horizontal components of the target block, and the vertical transform may represent a transform for vertical components of the target block. The vertical transform kernel/horizontal transform kernel may be adaptively determined based on a prediction mode and/or a transform index of a target block (CU or sub-block) including a residual block.

Further, according to an example, if the primary transform is performed by applying the MTS, a mapping relationship for transform kernels may be set by setting specific basis functions to predetermined values and combining basis functions to be applied in the vertical transform or the horizontal transform. For example, when the horizontal transform kernel is expressed as trTypeHor and the vertical direction transform kernel is expressed as trTypeVer, a trTypeHor or trTypeVer value of 0 may be set to DCT2, a trTypeHor or trTypeVer value of 1 may be set to DST7, and a trTypeHor or trTypeVer value of 2 may be set to DCT8.

In this case, MTS index information may be encoded and signaled to the decoding apparatus to indicate any one of a plurality of transform kernel sets. For example, an MTS index of 0 may indicate that both trTypeHor and trTypeVer values are 0, an MTS index of 1 may indicate that both trTypeHor and trTypeVer values are 1, an MTS index of 2 may indicate that the trTypeHor value is 2 and the trTypeVer value. Is 1, an MTS index of 3 may indicate that the trTypeHor value is 1 and the trTypeVer value is 2, and an MTS index of 4 may indicate that both trTypeHor and trTypeVer values are 2.

The transformer may derive modified (secondary) transform coefficients by performing the secondary transform based on the (primary) transform coefficients (S420). The primary transform is a transform from a spatial domain to a frequency domain, and the secondary transform refers to transforming into a more compressive expression by using a correlation existing between (primary) transform coefficients. The secondary transform may include a non-separable transform. In this case, the secondary transform may be called a non-separable secondary transform (NSST), or a mode-dependent non-separable secondary transform (MDNSST). The non-separable secondary transform may represent a transform which generates modified transform coefficients (or secondary transform coefficients) for a residual signal by secondary-transforming, based on a non-separable transform matrix, (primary) transform coefficients derived through the primary transform. At this time, the vertical transform and the horizontal transform may not be applied separately (or horizontal and vertical transforms may not be applied independently) to the (primary) transform coefficients, but the transforms may be applied at once based on the non-separable transform matrix. In other words, the non-separable secondary transform may represent a transform method in which the vertical and horizontal components of the (primary) transform coefficients are not separated, and for example, two-dimensional signals (transform coefficients) are rearranged to a one-dimensional signal through a certain determined direction (e.g., row-first direction or column-first direction), and then modified transform coefficients (or secondary transform coefficients) are generated based on the non-separable transform matrix. For example, according to a row-first order, M×N blocks are disposed in a line in an order of a first row, a second row, . . . , and an Nth row. According to a column-first order, M×N blocks are disposed in a line in an order of a first column, a second column, . . . , and an Nth column. The non-separable secondary transform may be applied to a top-left region of a block configured with (primary) transform coefficients (hereinafter, may be referred to as a transform coefficient block). For example, if the width (W) and the height (H) of the transform coefficient block are all equal to or greater than 8, an 8×8 non-separable secondary transform may be applied to a top-left 8×8 region of the transform coefficient block. Further, if the width (W) and the height (H) of the transform coefficient block are all equal to or greater than 4, and the width (W) or the height (H) of the transform coefficient block is less than 8, then a 4×4 non-separable secondary transform may be applied to a top-left min(8,W)×min(8,H) region of the transform coefficient block. However, the embodiment is not limited to this, and for example, even if only the condition that the width (W) or height (H) of the transform coefficient block is equal to or greater than 4 is satisfied, the 4×4 non-separable secondary transform may be applied to the top-left min(8,W)×min(8,H) region of the transform coefficient block.

Specifically, for example, if a 4×4 input block is used, the non-separable secondary transform may be performed as follows.

The 4×4 input block X may be represented as follows.

$\begin{matrix} {X = \begin{bmatrix} X_{00} & X_{01} & X_{02} & X_{03} \\ X_{10} & X_{11} & X_{12} & X_{13} \\ X_{20} & X_{21} & X_{22} & X_{23} \\ X_{30} & X_{31} & X_{32} & X_{33} \end{bmatrix}} & \left\lbrack {{Equation}\mspace{20mu} 1} \right\rbrack \end{matrix}$

If the X is represented in the form of a vector, the vector

may be represented as below. {right arrow over (X)}=[X ₀₀ X ₀₁ X ₀₂ X ₀₃ X ₁₀ X ₁₁ X ₁₂ X ₁₃ X ₂₀ X ₂₁ X ₂₂ X ₂₃ X ₃₀ X ₃₁ X ₃₂ X ₃₃]^(T)  [Equation 2]

In Equation 2, the vector

is a one-dimensional vector obtained by rearranging the two-dimensional block X of Equation 1 according to the row-first order.

In this case, the secondary non-separable transform may be calculated as below.

=T·

  [Equation 3]

In this equation,

represents a transform coefficient vector, and T represents a 16×16 (non-separable) transform matrix.

Through foregoing Equation 3, a 16×1 transform coefficient vector

may be derived, and the

may be re-organized into a 4×4 block through a scan order (horizontal, vertical, diagonal and the like). However, the above-described calculation is an example, and hypercube-Givens transform (HyGT) or the like may be used for the calculation of the non-separable secondary transform in order to reduce the computational complexity of the non-separable secondary transform.

Meanwhile, in the non-separable secondary transform, a transform kernel (or transform core, transform type) may be selected to be mode-dependent. In this case, the mode may include the intra prediction mode and/or the inter prediction mode.

As described above, the non-separable secondary transform may be performed based on an 8×8 transform or a 4×4 transform determined based on the width (W) and the height (H) of the transform coefficient block. The 8×8 transform refers to a transform that is applicable to an 8×8 region included in the transform coefficient block when both W and H are equal to or greater than 8, and the 8×8 region may be a top-left 8×8 region in the transform coefficient block. Similarly, the 4×4 transform refers to a transform that is applicable to a 4×4 region included in the transform coefficient block when both W and H are equal to or greater than 4, and the 4×4 region may be a top-left 4×4 region in the transform coefficient block. For example, an 8×8 transform kernel matrix may be a 64×64/16×64 matrix, and a 4×4 transform kernel matrix may be a 16×16/8×16 matrix.

Here, to select a mode-based transform kernel, three non-separable secondary transform kernels may be configured per transform set for the non-separable secondary transform for both the 8×8 transform and the 4×4 transform, and there may be 35 transform sets. That is, 35 transform sets may be configured for the 8×8 transform, and 35 transform sets may be configured for the 4×4 transform. In this case, three 8×8 transform kernels may be included in each of the 35 transform sets for the 8×8 transform, and three 4×4 transform kernels may be included in each of the 35 transform sets for the 4×4 transform. The sizes of the transforms, the numbers of sets, and the numbers of transform kernels in each set mentioned above are merely for illustration. Instead, a size other than 8×8 or 4×4 may be used, n sets may be configured, and k transform kernels may be included in each set.

The transform set may be called an NSST set, and the transform kernel in the NSST set may be called an NSST kernel. The selection of a specific set from among the transform sets may be performed, for example, based on the intra prediction mode of the target block (CU or sub-block).

For reference, as an example, the intra prediction mode may include two non-directional (or non-angular) intra prediction modes and 65 directional (or angular) intra prediction modes. The non-directional intra prediction modes may include a planar intra prediction mode, which is intra prediction mode 0, and a DC intra prediction mode, which is intra prediction mode 1, and the directional intra prediction modes may include 65 intra prediction modes from intra prediction mode 2 to intra prediction mode 66. However, this is an example, and the present disclosure may be applied to cases where there are different numbers of intra prediction modes. According to circumstances, intra prediction mode 67 may be further used, and intra prediction mode 67 may represent a linear model (LM) mode.

FIG. 5 illustrates directional intra modes in 65 prediction directions.

Referring to FIG. 5, on the basis of intra prediction mode 34 having a left upward diagonal prediction direction, the intra prediction mode having a horizontal directionality and the intra prediction mode having vertical directionality may be classified. H and V of FIG. 5 mean horizontal directionality and vertical directionality, respectively, and numerals −32 to 32 indicate displacements in 1/32 units on the sample grid position. This may represent an offset for the mode index value. Intra prediction modes 2 to 33 have the horizontal directionality, and intra prediction modes 34 to 66 have the vertical directionality. Meanwhile, strictly speaking, intra prediction mode 34 may be considered as being neither horizontal nor vertical, but it may be classified as belonging to the horizontal directionality in terms of determining the transform set of the secondary transform. This is because the input data is transposed to be used for the vertical direction mode symmetrical on the basis of intra prediction mode 34, and the input data alignment method for the horizontal mode is used for intra prediction mode 34. Transposing input data means that rows and columns of two-dimensional block data M×N are switched into N×M data. Intra prediction mode 18 and intra prediction mode 50 may represent a horizontal intra prediction mode and a vertical intra prediction mode, respectively, and intra prediction mode 2 may be called a right upward diagonal intra prediction mode because it has a left reference pixel and predicts in a right upward direction. In the same manner, intra prediction mode 34 may be called a right downward diagonal intra prediction mode, and intra prediction mode 66 may be called a left downward diagonal intra prediction mode.

In this case, mapping between the 35 transform sets and the intra prediction modes may be, for example, represented as in the following table. For reference, if an LM mode is applied to a target block, the secondary transform may not be applied to the target block.

TABLE 2 Intra 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 mode set 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Intra 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 mode set 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 Intra 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 mode set 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 Intra 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 mode (LM) set 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 NULL

If a specific set is determined to be used, one of k transform kernels in the specific set may be selected through the non-separable secondary transform index. The encoding apparatus may derive a non-separable secondary transform index indicating a specific transform kernel based on the rate-distortion (RD) check, and may signal the non-separable secondary transform index to the decoding apparatus. The decoding apparatus may select one from among k transform kernels in the specific set based on the non-separable secondary transform index. For example, the NSST index value 0 may indicate a first non-separable secondary transform kernel, the NSST index value 1 may indicate a second non-separable secondary transform kernel, and the NSST index value 2 may indicate a third non-separable secondary transform kernel. Alternatively, the NSST index value 0 may indicate that the first non-separable secondary transform is not applied to a target block, and the NSST index values 1 to 3 may indicate the three transform kernels.

Referring back to FIG. 4, the transformer may perform the non-separable secondary transform based on the selected transform kernels, and may obtain modified (secondary) transform coefficients. As described above, the modified transform coefficients may be derived as transform coefficients quantized through the quantizer, and may be encoded and signaled to the decoding apparatus and transferred to the dequantizer/inverse transformer in the encoding apparatus.

As described above, if the secondary transform is omitted, (primary) transform coefficients, which are an output of the primary (separable) transform, may be derived as transform coefficients quantized through the quantizer as described above, and may be encoded and signaled to the decoding apparatus and transferred to the dequantizer/inverse transformer in the encoding apparatus.

The inverse transformer may perform a series of procedures in the inverse order to that in which they have been performed in the above-described transformer. The inverse transformer may receive (dequantized) transformer coefficients, and derive (primary) transform coefficients by performing a secondary (inverse) transform (S450), and may obtain a residual block (residual samples) by performing a primary (inverse) transform on the (primary) transform coefficients (S460). In this connection, the primary transform coefficients may be called modified transform coefficients from the viewpoint of the inverse transformer. As described above, the encoding apparatus and the decoding apparatus may generate the reconstructed block based on the residual block and the predicted block, and may generate the reconstructed picture based on the reconstructed block.

The decoding apparatus may further include a secondary inverse transform application determinator (or an element to determine whether to apply a secondary inverse transform) and a secondary inverse transform determinator (or an element to determine a secondary inverse transform). The secondary inverse transform application determinator may determine whether to apply a secondary inverse transform. For example, the secondary inverse transform may be an NSST or an RST, and the secondary inverse transform application determinator may determine whether to apply the secondary inverse transform based on a secondary transform flag obtained by parsing the bitstream. In another example, the secondary inverse transform application determinator may determine whether to apply the secondary inverse transform based on a transform coefficient of a residual block.

The secondary inverse transform determinator may determine a secondary inverse transform. In this case, the secondary inverse transform determinator may determine the secondary inverse transform applied to the current block based on an NSST (or RST) transform set specified according to an intra prediction mode. In an embodiment, a secondary transform determination method may be determined depending on a primary transform determination method. Various combinations of primary transforms and secondary transforms may be determined according to the intra prediction mode. Further, in an example, the secondary inverse transform determinator may determine a region to which a secondary inverse transform is applied based on the size of the current block.

Meanwhile, as described above, if the secondary (inverse) transform is omitted, (dequantized) transform coefficients may be received, the primary (separable) inverse transform may be performed, and the residual block (residual samples) may be obtained. As described above, the encoding apparatus and the decoding apparatus may generate the reconstructed block based on the residual block and the predicted block, and may generate the reconstructed picture based on the reconstructed block.

In the present disclosure, a reduced secondary transform (RST) in which the size of a transform matrix (kernel) is reduced may be applied in the concept of NSST in order to reduce the amount of computation and memory required for the non-separable secondary transform.

The transform kernel, the transform matrix, and the coefficient constituting the transform kernel matrix, that is, the kernel coefficient or the matrix coefficient, described in the present disclosure may be expressed in 8 bits. This may be a condition for implementation in the decoding apparatus and the encoding apparatus, and may reduce the amount of memory required to store the transform kernel with a performance degradation that can be reasonably accommodated compared to the existing 9 bits or 10 bits. In addition, the expressing of the kernel matrix in 8 bits may allow a small multiplier to be used, and may be more suitable for single instruction multiple data (SIMD) instructions used for optimal software implementation.

In the present specification, the term “RST” may mean a transform which is performed on residual samples for a target block based on a transform matrix whose size is reduced according to a reduced factor. In the case of performing the reduced transform, the amount of computation required for transform may be reduced due to a reduction in the size of the transform matrix. That is, the RST may be used to address the computational complexity issue occurring at the non-separable transform or the transform of a block of a great size.

RST may be referred to as various terms, such as reduced transform, reduced secondary transform, reduction transform, simplified transform, simple transform, and the like, and the name which RST may be referred to as is not limited to the listed examples. Alternatively, since the RST is mainly performed in a low frequency region including a non-zero coefficient in a transform block, it may be referred to as a Low-Frequency Non-Separable Transform (LFNST).

When the secondary inverse transform is performed based on RST, the inverse transformer 235 of the encoding apparatus 200 and the inverse transformer 322 of the decoding apparatus 300 may include an inverse reduced secondary transformer which derives modified transform coefficients based on the inverse RST of the transform coefficients, and an inverse primary transformer which derives residual samples for the target block based on the inverse primary transform of the modified transform coefficients. The inverse primary transform refers to the inverse transform of the primary transform applied to the residual. In the present disclosure, deriving a transform coefficient based on a transform may refer to deriving a transform coefficient by applying the transform.

FIG. 6 is a diagram illustrating an RST according to an embodiment of the present disclosure.

In the present specification, the term “target block” may mean a current block or a residual block on which coding is performed.

In the RST according to an example, an N-dimensional vector may be mapped to an R-dimensional vector located in another space, so that the reduced transform matrix may be determined, where R is less than N. N may mean the square of the length of a side of a block to which the transform is applied, or the total number of transform coefficients corresponding to a block to which the transform is applied, and the reduced factor may mean an R/N value. The reduced factor may be referred to as a reduced factor, reduction factor, simplified factor, simple factor or other various terms. R may be referred to as a reduced coefficient, but according to circumstances, the reduced factor may mean R. Further, according to circumstances, the reduced factor may mean the N/R value.

In an example, the reduced factor or the reduced coefficient may be signaled through a bitstream, but the example is not limited to this. For example, a predefined value for the reduced factor or the reduced coefficient may be stored in each of the encoding apparatus 200 and the decoding apparatus 300, and in this case, the reduced factor or the reduced coefficient may not be signaled separately.

The size of the reduced transform matrix according to an example may be R×N less than N×N, the size of a conventional transform matrix, and may be defined as in Equation 4 below.

$\begin{matrix} {T_{RxN} = \begin{bmatrix} t_{11} & t_{12} & t_{13} & \ldots & t_{1\; N} \\ t_{21} & t_{22} & t_{23} & \; & t_{2\; N} \\ \; & \vdots & \; & \ddots & \vdots \\ t_{R\; 1} & t_{R\; 2} & t_{R\; 3} & \ldots & t_{RN} \end{bmatrix}} & \left\lbrack {{Equation}\mspace{20mu} 4} \right\rbrack \end{matrix}$

The matrix T in the Reduced Transform block shown in FIG. 6A may mean the matrix T_(R×N) of Equation 4. As shown in FIG. 6A, when the reduced transform matrix T_(R×N) is multiplied to residual samples for the target block, transform coefficients for the target block may be derived.

In an example, if the size of the block to which the transform is applied is 8×8 and R=16 (i.e., R/N=16/64=1/4), the RST according to FIG. 6A may be expressed as a matrix operation as shown in Equation 5 below. In this case, memory and multiplication calculation can be reduced to approximately ¼ by the reduced factor.

In this document, matrix operation can be understood as an operation to obtain a column vector by multiplying the matrix and the column vector by placing the matrix on the left side of the column vector.

$\begin{matrix} {\begin{bmatrix} t_{1,1} & t_{1,2} & t_{1,3} & \ldots & t_{1,64} \\ t_{2,1} & t_{2,2} & t_{2,3} & \; & t_{2,64} \\ \; & \vdots & \; & \ddots & \vdots \\ t_{16,1} & t_{16,2} & t_{16,3} & \ldots & t_{16,64} \end{bmatrix} \times \begin{bmatrix} r_{1} \\ r_{2} \\ \vdots \\ r_{64} \end{bmatrix}} & \left\lbrack {{Equation}\mspace{14mu} 5} \right\rbrack \end{matrix}$

In Equation 5, r₁ to r₆₄ may represent residual samples for the target block and may be specifically transform coefficients generated by applying a primary transform. As a result of the calculation of Equation 5, transform coefficients c_(i) for the target block may be derived, and a process of deriving c_(i) may be as in Equation 6.

  Equation 6 for i from to R:  ci=0  for j from 1 to N   ci += tij * rj

As a result of the calculation of Equation 6, transform coefficients c₁ to c_(R) for the target block may be derived. That is, when R=16, transform coefficients c₁ to c₁₆ for the target block may be derived. If, instead of RST, a regular transform is applied and a transform matrix of 64×64 (N×N) size is multiplied to residual samples of 64×1 (N×1) size, then only 16 (R) transform coefficients are derived for the target block because RST was applied, although 64 (N) transform coefficients are derived for the target block. Since the total number of transform coefficients for the target block is reduced from N to R, the amount of data transmitted by the encoding apparatus 200 to the decoding apparatus 300 decreases, so efficiency of transmission between the encoding apparatus 200 and the decoding apparatus 300 can be improved.

When considered from the viewpoint of the size of the transform matrix, the size of the regular transform matrix is 64×64 (N×N), but the size of the reduced transform matrix is reduced to 16×64 (R×N), so memory usage in a case of performing the RST can be reduced by an R/N ratio when compared with a case of performing the regular transform. In addition, when compared to the number of multiplication calculations N×N in a case of using the regular transform matrix, the use of the reduced transform matrix can reduce the number of multiplication calculations by the R/N ratio (R×N).

In an example, the transformer 232 of the encoding apparatus 200 may derive transform coefficients for the target block by performing the primary transform and the RST-based secondary transform on residual samples for the target block. These transform coefficients may be transferred to the inverse transformer of the decoding apparatus 300, and the inverse transformer 322 of the decoding apparatus 300 may derive the modified transform coefficients based on the inverse reduced secondary transform (RST) for the transform coefficients, and may derive residual samples for the target block based on the inverse primary transform for the modified transform coefficients.

The size of the inverse RST matrix T_(N×R) according to an example is N×R less than the size N×N of the regular inverse transform matrix, and is in a transpose relationship with the reduced transform matrix T_(R×N) shown in Equation 4.

The matrix Tt in the Reduced Inv. Transform block shown in FIG. 6B may mean the inverse RST matrix T_(R×N) ^(T) (the superscript T means transpose). When the inverse RST matrix T_(R×N) ^(T) is multiplied to the transform coefficients for the target block as shown in FIG. 6B, the modified transform coefficients for the target block or the residual samples for the target block may be derived. The inverse RST matrix T_(R×N) ^(T) may be expressed as (T_(R×N) ^(T))_(N×R).

More specifically, when the inverse RST is applied as the secondary inverse transform, the modified transform coefficients for the target block may be derived when the inverse RST matrix T_(R×N) ^(T) is multiplied to the transform coefficients for the target block. Meanwhile, the inverse RST may be applied as the inverse primary transform, and in this case, the residual samples for the target block may be derived when the inverse RST matrix T_(R×N) ^(T) is multiplied to the transform coefficients for the target block.

In an example, if the size of the block to which the inverse transform is applied is 8×8 and R=16 (i.e., R/N=16/64=1/4), then the RST according to FIG. 6B may be expressed as a matrix operation as shown in Equation 7 below.

$\begin{matrix} {\begin{bmatrix} t_{1,1} & t_{2,1} & \; & t_{16,1} \\ t_{1,2} & t_{2,2} & \ldots & t_{16,2} \\ t_{1,3} & t_{2,3} & \; & t_{16,3} \\ \vdots & \vdots & \; & \vdots \\ \vdots & \; & \ddots & \vdots \\ t_{1,64} & t_{2,64} & \ldots & t_{16,64} \end{bmatrix} \times \begin{bmatrix} c_{1} \\ c_{2} \\ \vdots \\ c_{16} \end{bmatrix}} & \left\lbrack {{Equation}\mspace{14mu} 7} \right\rbrack \end{matrix}$

In Equation 7, c₁ to c₁₆ may represent the transform coefficients for the target block. As a result of the calculation of Equation 7, r_(j) representing the modified transform coefficients for the target block or the residual samples for the target block may be derived, and the process of deriving r_(j) may be as in Equation 8.

  Equation 8 for i from to N:  ri=0  for j from 1 to R   ri += tji * cj

As a result of the calculation of Equation 8, r₁ to r_(N) representing the modified transform coefficients for the target block or the residual samples for the target block may be derived. When considered from the viewpoint of the size of the inverse transform matrix, the size of the regular inverse transform matrix is 64×64 (N×N), but the size of the reduced inverse transform matrix is reduced to 64×16 (R×N), so memory usage in a case of performing the inverse RST can be reduced by an R/N ratio when compared with a case of performing the regular inverse transform. In addition, when compared to the number of multiplication calculations N×N in a case of using the regular inverse transform matrix, the use of the reduced inverse transform matrix can reduce the number of multiplication calculations by the R/N ratio (N×R).

A transform set configuration shown in Table 2 may also be applied to an 8×8 RST. That is, the 8×8 RST may be applied according to a transform set in Table 2. Since one transform set includes two or three transforms (kernels) according to an intra prediction mode, it may be configured to select one of up to four transforms including that in a case where no secondary transform is applied. In a transform where no secondary transform is applied, it may be considered to apply an identity matrix. Assuming that indexes 0, 1, 2, and 3 are respectively assigned to the four transforms (e.g., index 0 may be allocated to a case where an identity matrix is applied, that is, a case where no secondary transform is applied), an NSST index as a syntax element may be signaled for each transform coefficient block, thereby designating a transform to be applied. That is, through the NSST index, it is possible to designate an 8×8 NSST for atop-left 8×8 block and to designate an 8×8 RST in an RST configuration. The 8×8 NSST and the 8×8 RST refer to transforms applicable to an 8×8 region included in the transform coefficient block when both W and H of the target block to be transformed are equal to or greater than 8, and the 8×8 region may be a top-left 8×8 region in the transform coefficient block. Similarly, a 4×4 NSST and a 4×4 RST refer to transforms applicable to a 4×4 region included in the transform coefficient block when both W and H of the target block to are equal to or greater than 4, and the 4×4 region may be a top-left 4×4 region in the transform coefficient block.

If the (forward) 8×8 RST illustrated in Equation 4 is applied, 16 significant transform coefficients are generated. Thus, it is considered that 64 pieces of input data forming the 8×8 region is reduced to 16 pieces of output data, and only ¼ of the region is filled with significant transform coefficients from the perspective of a two-dimensional region. Accordingly, the 16 pieces of output data obtained by applying the forward 8×8 RST, for example, the top-left region (transform coefficients 1 to 16, that is, c₁, c₂, . . . , c₁₆ obtained through Equation 6) of the block as shown in FIG. 7, may be filled in the diagonal direction scanning order from 1 to 16.

FIG. 7 is a diagram illustrating a transform coefficient scanning order according to an embodiment of the present disclosure. As described above, when the forward scanning order starts from a first transform coefficient, reverse scanning may be performed in directions and orders indicated by arrows shown in FIG. 7 from 64th to 17th transform coefficients in the forward scanning order.

In FIG. 7, a top-left 4×4 region is a region of interest (ROI) filled with significant transform coefficients, and the remaining region is empty. The empty region may be filled with 0s by default.

That is, when an 8×8 RST with a 16×64 forward transform matrix is applied to the 8×8 region, output transform coefficients may be arranged in the top-left 4×4 region, and the region where no output transform coefficient exists may be filled with 0s (from the 64th to 17th transform coefficients) according to the scanning order of FIG. 7.

If a non-zero significant transform coefficient is found outside the ROI of FIG. 7, it is certain that the 8×8 RST has not been applied, and thus NSST index coding may be omitted. On the contrary, if a non-zero transform coefficient is not found outside the ROI of FIG. 7 (e.g., if a transform coefficient is set to 0 in a region other than the ROI in a case where the 8×8 RST is applied), the 8×8 RST is likely to have been applied, and thus NSST index coding may be performed. This conditional NSST index coding may be performed after a residual coding process because it is necessary to check the presence or absence of a non-zero transform coefficient.

The present disclosure discloses methods for optimizing a design and an association of an RST that can be applied to a 4×4 block from an RST structure described in this embodiment. Some concepts can be applied not only to a 4×4 RST but also to an 8×8 RST or other types of transforms.

FIG. 8 is a flowchart illustrating an inverse RST process according to an embodiment of the present disclosure.

Each operation disclosed in FIG. 8 may be performed by the decoding apparatus 300 illustrated in FIG. 3. Specifically, S800 may be performed by the dequantizer 321 illustrated in FIG. 3, and S810 and S820 may be performed by the inverse transformer 322 illustrated in FIG. 3. Therefore, a description of specific details overlapping with those explained above with reference to FIG. 3 will be omitted or will be made briefly. In the present disclosure, an RST may be applied to a transform in a forward direction, and an inverse RST may mean a transform applied to an inverse direction.

In an embodiment, the specific operations according to the inverse RST may be different from the specific operations according to the RST only in that their operation orders are opposite to each other, and the specific operations according to the inverse RST may be substantially similar to the specific operations according to the RST. Accordingly, a person skilled in the art will readily understand that the descriptions of S800 to S820 for the inverse RST described below may be applied to the RST in the same or similar manner.

The decoding apparatus 300 according to an embodiment may derive the transform coefficients by performing dequantization on the quantized transform coefficients for the target block (S800).

The decoding apparatus 300 may determine whether to apply an inverse secondary transform after an inverse primary transform and before the inverse secondary transform. For example, the inverse secondary transform may be an NSST or an RST. For example, the decoding apparatus may determine whether to apply the inverse secondary transform based on a secondary transform flag parsed from a bitstream. In another example, the decoding apparatus may determine whether to apply the inverse secondary transform based on a transform coefficient of a residual block.

The decoding apparatus 300 may determine an inverse secondary transform. In this case, the decoding apparatus 300 may determine the secondary inverse transform applied to the current block based on an NSST (or RST) transform set specified according to an intra prediction mode. In an embodiment, a secondary transform determination method may be determined depending on a primary transform determination method. For example, it may be determined to apply an RST or LFNST only when DCT-2 is applied as a transform kernel in the primary transform. Alternatively, various combinations of primary transforms and secondary transforms may be determined according to the intra prediction mode.

Further, in an example, the decoding apparatus 300 may determine a region to which the inverse secondary transform is applied based on the size of the current block before determining the inverse secondary transform.

The decoding apparatus 300 according to an embodiment may select a transform kernel (S810). More specifically, the decoding apparatus 300 may select the transform kernel based on at least one of informations on a transform index, a width and height of a region to which the transform is applied, an intra prediction mode used in image decoding, and a color component of the target block. However, the example is not limited to this, and for example, the transform kernel may be predefined, and separate information for selecting the transform kernel may not be signaled.

In one example, information on the color component of the target block may be indicated through CIdx. If the target block is a luma block, CIdx may indicate 0, and if the target block is a chroma block, for example, a Cb block or a Cr block, then CIdx may indicate a non-zero value (for example, 1).

The decoding apparatus 300 according to an embodiment may apply the inverse RST to transform coefficients based on the selected transform kernel and the reduced factor (S820).

Hereinafter, a method for determining a secondary NSST set, that is, a secondary transform set or a transform set, in view of an intra prediction mode and the size of a block according to an embodiment of the present disclosure is proposed.

In an embodiment, a set for a current transform block may be configured based on the intra prediction mode described above, thereby applying a transform set including transform kernels having various sizes to the transform block. Transform sets in Table 3 are expressed using 0 to 3 as in Table 4.

TABLE 3 Intra 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 mode NSST 0 0 2 2 2 2 2 2 2 2 2 2 2 18 18 18 18 Set Intra 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 mode NSST 34 34 34 34 34 34 34 34 34 34 34 18 18 18 18 18 18 Set Intra 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 mode NSST 18 18 18 18 18 18 18 34 34 34 34 34 34 34 34 34 34 Set Intra 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 mode NSST 18 18 18 18 18 2 2 2 2 2 2 2 2 2 2 2 Set

TABLE 4 Intra 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 mode NSST 0 0 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 Set Intra 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 mode NSST 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 Set Intra 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 mode NSST 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 Set Intra 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 mode NSST 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 Set

Indexes 0, 2, 18, and 34 illustrated in Table 3 correspond to 0, 1, 2, and 3 in Table 4, respectively. In Table 3 and Table 4, only four transform sets are used instead of 35 transform sets, thereby significantly reducing memory space.

Various numbers of transform kernel matrices that may be included in each transform set may be set as shown in the following tables.

TABLE 5 0 NSST Set (DC, Planar) 1 2 3 # of transform kernels 2 2 2 2

TABLE 6 0 NSST Set (DC, Planar) 1 2 3 # of transform kernels 2 1 1 1

TABLE 7 0 NSST Set (DC, Planar) 1 2 3 # of transform kernels 1 1 1 1

According to Table 5, two available transform kernels are used for each transform set, and accordingly a transform index ranges from 0 to 2.

According to Table 6, two available transform kernels are used for transform set 0, that is, a transform set according to a DC mode and a planar mode among intra prediction modes, and one transform kernel is used for each of the remaining transform sets. Here, an available transform index for transform set 1 ranges from 0 to 2, and a transform index for the remaining transform sets 1 to 3 ranges from 0 to 1.

According to Table 7, one available transform kernel is used for each transform set, and accordingly a transform index ranges from 0 to 1.

In transform set mapping of Table 3, a total of four transform sets may be used, and the four transform sets may be rearranged to be distinguished by indexes 0, 1, 2, and 3 as shown in Table 4. Table 8 and Table 9 illustrate four transform sets available for secondary transform, wherein Table 8 presents transform kernel matrices applicable to an 8×8 block, and Table 9 presents transform kernel matrices applicable to a 4×4 block. Table 8 and Table 9 include two transform kernel matrices per transform set, and two transform kernel matrices may be applied to all intra prediction modes as shown in Table 5.

TABLE 8 const Int g_alNsst8x8[4][2][16][64] = {  { //0   {    {−120, 18, 20, 3, 4, 1, 2, 1, 28, −15, −3, 0, −1, 0, 0, 0, 15, 0, −3, 0, −1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 3, 0, −1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1.0.0, 0, 0, 0, 0, 0},    {−19,−90,44,−1,9,0,3,0,−61,30,−7,3,0,1,0,0,32,1,−7,−1,2,0,−1,0,−3,3,−1,0,0,0,0,0,7,2,−2,0,0,0,0,0,−1,1,0,0,0,0,0,0,0,2,1 −1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {−10,67,−11,−6,−3,−2,−1,−1,−93,1,31,0,4,0,2,0,29,−31,−2,4,0,1,0,0,6,2,−4,0,0,0,0,0,6,−3,0,0,0,0,0,0,1,0,−1,0,0,0,0,2, −1,0,0,0,0,0,0,1,0,0,0,0,0,0,0},    {15,−16,15,−1,0,0,0,0,−10,−113,17,16,4,3,2,1,21,22,−30,−1,0,0,−1,0,−4,15,2,−6,0,−1,0,0,1,4,−1,0,0,0,0,−1,3,0, −1,0,0,0,0,0,1,−1,0,0,0,0,0,−1,1,0,0,0,0,0,0},    {−28,−41,−99,45,−6,10,,3,4,−23,−14,13,−13,6,−2,2,−1,−14,15,17,−8,−1,−10,1,0,−1,11,−3,−1,1,−1,0,0,0,0,4,2, −2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1,1,1−1,0,0,0,0,1,0,0,0,0,0,0,0,0},    {13,5,−34,7,−2,2,−1,1,31,17,−11,−4,−2,−1,−1,0,103,3,−12,−4,−4,1,−2,−1,−48,10,11,0,2,0,1,0,7,−4,2,0,0,0,0,0,0, −9,1,2,0,0,0,0,0,0,3,−1,1,0,0,0,0,0,−4,0,1,0,0,0,0,0},    {3,−31,−1,3,1,0,0,0,35,−3,73,−14,−1,−3,0,−1,6,−83−2,24,−1,4,0,2,8,16,−26,−1,2,−1,0,0,−4,1,2,−2,1,0,0,0,1,3,−4,0,0,0,0,0, −1,0,1,0,0,0,0,0,0,1,−1,1,0,0,0,0,0},    {0,6,14,−4,2,0,0,0,8,27,91,−16,−2,−4,1,−2,4,79,−9,0,−3,−2,−1,−1,−4,−19,3,2,2,1,1,0,−1,2,−6,2,1,1,0,0,0,−3,−1,1,0,0,0,0,0,1, −1,1,0,0,0,0,0,−1,−1,0,0,0,0,0},    {−12,−15,−40,−112,22,−11,6,−4,−4,8,−4,8,11,3,−1,1,−2,10,14,21,−70,−1,0,−5,−2,4,4,2,−1,0,0,1,0,2,3,0,0,0,0, −1,0,0,1,0,0,0,0,0,0,1,2,0,0,0,0,0,0,0,0,0,0,0,0},    {10,3,−5,−7,1,0,1,0,14,8,−13,1,−11,1,0,0,44,16,−10,−3,−3,−1,1,0,111,10,−19,−2,−4,−1,−2,0,−17,125,−2,1,0,0,0,9, −2,0,0,0,0,0,0,−5,1,1,0,0,0,0,0,3,0,0,0,0,0,0,0},    {10,0,24,8,0,1,1,0,0,−30,−7,−52,6,−3,2,−1,25,−3,83,0,−17,0,−2,0,3,−49,−14,35,2,2,0,1,2,4,−16,−6,4,0,1,0,0,−2,1,2, −1,0,0,0,1,2,−2,−1,0,0,0,0,0,−1,0,1,0,0,0,0},    {0,2,2,−3,9,−4,2,−1,3,2,14,62,−11,5,−3,2,5,13,17,−38,4,−3,1,−1,−6,49,−44,−16,3,−1,0,−1,9,−21,−3,9,−1,0,0,0,−4,7,−2, −2,0,0,0,0,2,−3,1,1,0,0,0,0,−1,2,−1,−1,0,0,0,0},    {0,−7,−11,−3,1,−2,−1,0,7,0,10,79,−4,4,−2,1,11,−18,−60,18,−1,2,0,5,−91,−31,1,6,0,2,−1,8,−22,2,−1,0,0,0,2,−4,3,−5, −1,0,0,0,1,2,−3,0,0,0,0,0,0,−1,0,−2,0,0,0,0},    {4,2,−3,−1,0,0,0,0,7,3,1,−5,−2,1,0,0,−6,−1,−6,−3,4,−1,1,0,18,1,1,3,3,0,0,0,0,107,36,−39,−9,−4,−1,−2,0,−32,−1,14, −3,0,0,0,0,11,0,−4,1,0,0,0,0,−3,1,1,0,0,0,0,0},    {5,8,−3,28,109,−24,11,−3,−1,−1,3,−3,−34,15,−3,2,−4,−3,−10,−4,−35,2,−1,0,1,−6,6,0,11,−4,0,0,0,2,1,1,−1,1,1,0,0, −1,0,0,1,0,0,0,0,0,0,0,−2,0,0,0,0,0,0,1,0,0,0},    {1,−6,4,−12,1,−1,0,0,6,−4,21,−11,−2,−1,1,−1,5,−22,14,−73,9,−4,1,0,16,−6,78,−13,−30,2,−5,0,1,−5,7,41,−7,−2,−1,−1,1,−3, −2,2,4,0,1,0,0,−2,1,4,−1,0,0,0,1,0,−1,1,1,0,0,0},    }.     {      {108,−49,−8,−1,−1,−1,−1,0,−46,6,9,1,1,0,10,−8,9,1,−1,0,0,0,0,−3,1,−1,0,0,0,0,0−1,1,0,0,0,0,0,0,−1,1,0,0,0,0,0,0, −1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},      {57,58,−35,−5,−6,−1,−2,0,73,−31,−20,5,−1,1,−1,0,−35,−19,1,4,5,1,1,1,0,−7,4,5,−2,0,0,0,0,−7,0,1,0,0,0,0,0,−1,1,1,0,0,0,0,0,−2, −1,1,0,0,0,0,0,0,0,0,0,0,0,0,0},      {−5,90,31,1,10,15,1,2,1,82,0,−6,−5,−4,−1,−1,0,−16,5,−1,−2,1,0,0,0,−10,6,1,0,1,0,0,0,−5,4,−1,−1,0,0,0,0,−1,1,0,0,0,0,0,0, −1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},      {24,24,34,−16,0,−4,0,−2,21,90,−31,−19,−3,−3,−1,−1,29,−28,36,6,2,2,0,1,−13,−19,6,11,1,1,0,0,−1,−4,3,2,−1,0,0,0,−3, −2,2,1,0,0,0,0,0,−1,0,0,0,0,0,0,−1,−1,1,0,0,0,0,0},      {7,25,93,−33,−1,−6,1,−3,−15,−19,11,−14,4,0,1,0,−66,−10,4,6,1,1,0,14,15,−7,0,0,−1,0,0,2,0,−8,1,0,0,0,04,1,−2,1,0,0,0,0,−1,−1, −2,1,0,0,0,0,1,0,−1,0,0,0,0,0},      {20,8,45,−16,−1,−3,1,−1,1,1,−68,7,5,3,1,1,1,88,−4,−180,−3,0,−1,0,−23,−2,2,1,1,0,0,0,−3,5,0,0,1,0,0,0, −4,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,−2,0,0,0,0,0,0,0},      {12,−24,3,−15,6,−2,2,−1,−29,−14,−71,26,5,3,0,2,−3,70,31,32,−4,3,0,1,−10,23,29,−13,−7,−1,−1,−1,4,5,−3,−7,0,0,0,0,−1,3,2, −2,1,0,0,0,2,0,0,0,0,0,0,0,01,1,−1,0,0,0,0},      {−1,−5,−8,−51,8,−4,3,−1,3,−7,−71,9,13,0,1,1,7,77,−5,14,−5,−2,−1,−1,37,−9,−16,2,−6,1,−1,0,−2,−2,11,5,7,−1,1,0,0,2,−1,2,0,−1,0,0,0, −2,0,1,1,0,0,0,0,1,−1,0,0,0,0,0,0},      {8,10,23,97,−6,2,−4,2,−12,−22,−54,−10,10,3,0,1,−8,6,−37,−7,8,2,1,024,−9,0,120,−1,0,0,0,−4,6,0,−1,0,0,0,2,0,3,0,−1,0,0,0, −1,0,0,−1,0,0,0,1,0,1,0,0,0,0,0},      {14,21,34,36,1,−1,0,0,13,36,2,38,−6,1,−2,1,29,29,70,−7,−18,−2,−2,−1,16,34,−2,−38,−5,−2,−1,−1,2,−3,−16−9,3,1,1,0,0,1,−2, 2,1,1,0,0,01,−1,−2,−1,1,0,0,0,0,0,0,−1,0,0,0,0},      {8,−11,−6,−8,0,0,0,0,15,−3,22,−1,0,0,0,0,22,−49,−6,7,2,2,0,1,107,1,−24,1,−2,−1,−2,0,14,−12,5,3,0,0,0,0,0,0,4,0,−1,0,0,0, −3,0,1,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,0},      {0,−2,−11,−4,−23,3,−3,1,−3,−3,−17,−102,−10,9,2,0,21,5,37,−4,30,0,0,−1,0,39,0,−3,3,−10,0,−1,1,0,−17,3,3,−1,1,0,−1,1,2,5,0, −1,0,0,1,−1,−2,0,1,0,0,0,−1,0,0,2,0,0,0,0},      {−2,−4,2,−9,−1,1,1,1,−6,−1,−25,11,−11,2,−4,1,−2,−24,13,67,−10,3,0,01,−15,−1,−63,−4,53,1,5,0,−1,−8,1,52,6,−9,2,−1,−1,0,5,2,−9, −1,−2,0,0,−3,1,4,0,−2,0,0,0,0,1,0,−2,0,1,0},      {1,−4,16,−1,−6,2,−1,0,−2,−8,−1,−19,−94,−1,0,0,−5,61,−8,−3,1,−1,0,9,−98,26,1.2,1,0,1,−8,−21,27,−2,1,0,0,0,1,3,−1,−2,2,−1.0,0, −3,2,3,−1,0,0,0,0,1,0,0,−1,1,0,0,0},      {−4,−6,2,−14,−102,27,−5,2,0,4,−1,36,−35,22,−6,2,−1,5,−13,6,37,−1,−3,1,2,−1,3,−10,8,−7,1,0,−1,1,0,−6,6,−2,0,0,0,0,0,−1,2, −1,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0},      {−1,−1,2,20,1,−6,−2,0,−1,0,7,4,11,−11,4,0,1,−4,17,7729,21,0,−26,−24,−75,3,−13,−5,−10,−11,−18,−25,18,0,3,1,1,1,2,11,4, 5,0,0,0,0,−1,−2,0,0,0,0,0,−1,0,0,1,−2,0,0,0},     }    },   { //1    {      {−98,52,−1,4,0,1,0,1,58,−7,−13,0,−2,0,−1,0,3,−18,2,3,0,0,0,0,2,−1,5,0,0,0,0,0,0,−2,0,−1,0,0,0,0,1,0,1,0,0,0,0,0,0, −1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},      {66,7,−16,0,−3,0,−1,0,89,−43,−15,1,−2,0,−1,0,−24,−24,13,4,2,1,1,0,−11,59,−2,0,0,0,0,−10,3,1,−1,1,0,0,0,−4,3,1,0,0,0,0,0, −4,1,0,0,0,0,0,0,−2,1,0,0,0,0,0,0},      {−15,18,−11,4,−3,2,−1,1,−23,−71,36,1,5,1,2,0,−56,50,33,−12,2,−2,1,16,28,−20,−13,0,0−1,0,−1,−1,0,−12,1,4,1,0,0,5,1,−4,4,1, −1,0,0,0,0,−1,2,0,−1,0,0,3,0,−1,−1,−1,0,0,0,},      {−35,100,46,−2,8,0,3,0,39,−7,22,−8,0,−2,0,−1,−9,4,5,−8,1,−1,0,0,−11,17,0,−5,2,0,1,0,−3,9,−8,−1,2,0,0,0,−1,4,−3,2,1,0,0,0,0,2, −2,1,0,0,0,0,−1,1,−1,0,0,0,0,0},      {7,3,−11,1,1−1,0,0,0,41,9,33,−14,3,−4,1,−1,10,64,−54,−18,1,−3,0,−1,15,−40,30,4,3,0,1,−3,−12,21,18,−9,−1,−10,2,−6,5,−6, −8,2,0,0,−3,−2,3,−3,1,3,0,0,0,−1,1,0,01,0,0,0}      {−2,−7,−18,7,−4,2,−1,1,−5,−60,32,8,0,2,0,1,97,−9,20,−15,−4,2,1,−1,−13,−22,2,−15,3,0,1,0,−7,7,5,−3,8,0,1,0,0−4,4,−1,0,3,−2,0, −1,−1,3,0,0,0,−1,0,0,−2,1,−1,−1,0,0,0,0},      {−19,25,22,10,20,2,0,1,−27,−46,−4,8,3,0,1,0,−34,−28,26,21,4,2,1,1,−9,36,33,44,−2,201,3,14,52,1,−21,−4,−3,−1,4,7,9,−24, −13,2,0,0,0,3,1,−12,1,1,4,1,1,1,2,0,−4,3,2,0,0},      {2,2,−12,8,0,4,−1,1,6,5,31,−15,−2,−3,0,−1,−6,11,−30,10,3,4,0,1,27,−16,52,0,−19,0,−4,0,−5,16,−13,69,15,9,1,1,−8,3, 32,21,44,−6,2,0,−1,7,3,2,1,−8,−12,1,−2,0,−2,−4,1,−3,2,0,0},      {6,35,20,−2,−1,1,0,0,−6,17,57,−20,0,0−3,1,−1,−18,−24,−13,33,6,−3,2,−1,−78,5,2,7,17,0,4,0,−8,40,05,−1,−4,0,−1,2,10,−13,0, −3,1,0,0,4,3,−6,1,0,1,−1,0,0,−1,−4,1,0,0,−1,0},      {14,−31,−98,24,−8,6,−3,2,10,44,23,28,−6,4,−1,1,−14,−7,20,−18,8,−1,−1,−−1,13,8,−3,−9,7,2,1,0,5,1,−6,3,2,−1,0,0,1,−4,4,2, −1,0,0,0,1,1,1,−2,0,0,0,0,−1,−1,0,1,0,0,0,0},      {−1,−4,23,0,5,−1,0,0,−3,−20,−3,18,9,−5,1,−1,25,−13,43,7,20,−3,4,0,7,70,−3,44,4,−10,1,−2,18,13,−37,8,−31,−9,−3,−2,−14,−30, −13,12,−13,10,2,3,2,−2,9,7,−3,8,−1,1,−1,2,4,3,−1,3,−1,0},      {10,14,18,9,−5,−1,0,0,16,25,29,18,−5,0,0,0,18,31,37,13,−11,−2,−1,−1,17,3,0,35,9,−18,−6,−3,2,14,19,25,−20,−40,−10,−5, −2,0,−4,−8,−49,−28,6,1,2,−2,−6,−12,−25,5,13,4,3,0,0,−4,−8,8,5,2,1},      {9,5,18,5,−2,3,0,1,0,3,53,−10,−6,0,−1,0,−11,−66,4,−31,0,0,1,0,65,−9,−10,15,2,3,0,32,−31,2,9,1,−3,0,−1,−1,−18,17,−2,5,0,0,0, −1,1,3,−7,1,1,0,0,0,1,0,01,1,0,0,0},      {0,0,−6,22,−10,1,−3,1,1,−1,15,−34,16,−3,4,−2,−3,7,−24,47,−18,1,−4,1,9,−15,36,−48,8,5,1,0,−13,21,−36,35,16,−17,3,−3,9, −11,21,4,−41,10,−1,1,−2,1,−4,−20,16,8,−4,2,2,−3,3,6,−1,−6,1,1},      {1,2,−4,10,1,1,0,0,0,−2,24,−20,−6,−2,2,−1,7,−6,−13,30,9,4,0,−1,−31,31,10,3,−53,3,−8,1,3,−42,3−13,10,30,−2,8,24,0,59, −11,25,−11,−4,−1,3,−1,−10,−29,4,−14,4,−2,−3,−2,−2,8,3,−1,3,−1},      {−3,3,−6,−88,7,−9,4,−4,4,−4,25,57,25,−4,4,0,−3,−8,29,17,−42,2,−3,−1,0,13,1,−13,−6,17,−3,2,0,2,3,0,12,−2,−2,0−,2,−8,5,0,0, 3,0,0,0,0,0,−3,0,−2,0,0,0,0,0,3,0,0,2,0},     }, {      {73,−47,5,−4,1,−1,1,0,−75,41,2,1,0,0,0,0,0,32,−5,−11,3,−2,1,−1,0,0−9,−8,0,0,0,0,0,3,6,−2,2,0,0,0,0,0,−2, −2,0,1,0,0,0,0,2,1,0,0,0,0,0,0,−1,−1,0,0,0,0,0,0},      {−77,−3,14,1,3,0,1,0,−10,57,−19,1,−3,1,−1,0,51,−49,4,6,−1,1,−1,0,−20,6,21,−7,2,−1,1,0,7,6,−14,−1,1,−1,0,0,−2,−4,4,4,4, −1,0,0,0,3,1,−1,−2,−1,0,0,0,−1,−1,1,1,0,0,0,0},      {51,−17,12,−3,1,−1,0,0,54,−1,−29,3,−4,1,−2,0,−10,−60,35,1,3,0,1,0,−31,50,4,−14,4,−3,1,−8,−6,−21,9,−1,1,0,0,−5,0,11,1, −2,1,0,0,1,0,−4,−3,1,0,0,0,−3,1,1,1,0,0,0,0},      {32,17,−22,7,−3,2,−1,1,54,0,12,−9,−1,2,0,−1,29,−19,−39,11,−2,2,−1,10,−49,51,2,−1,1,0,0,−21,39,−7,25,7,−4,2,−1,1,−9, −17,18,3,0,1,0,−3,4,9,1,−6,0,−1,01,−3,−2,1,0,2,0,0},      {−14,−74,28,1,5,1,1,0,33,44,−5,13,0,−2,0,−1,−57,11,−24,18,−2,3−1,1,40,−8,8,15,−2,−7,2,−1,1,−11.9,1−8,7,−1,1,0,1,9,0,3,−1, 1,0,0,−2,−3,−4,0,−1,1,0,0,2,0,4,0,0,0,0,0},      {20,12,13,−10,1,−2,1,−1,44,37,−26,11,−3,2,−1,1,44,9,−6,−15,−3,−2,−1,−1,9,−30,−46,20,13,−1,15,−38,49,7,−7,3,−1,1,−10,20, −6,−22,7,−3,1,−1,1,−10,−4,15,0,0,1,0,0−2,2,6,−5,−3,0,0,0},      {−12,−22,7,−14,3,−1,1,−1,−14,−24,−5,20,−3,2,−2,1,−14,−2,21,−1,65,−1,2,0,−13,8,14,25,21,−1,05,13,32,−51,−5,2,0,−1, −20,27,−57,9,31,−5,5,−1,9,−6,10,35,−24,−2,−1,0,−1,1,1,−17,−6,8,−1,1},      {−20,−75,−5,−1,0,0,0,0,32,−33,43,−1,4,−1,2,0,041,27,−6,−19,1,−4,0,−1,47,1,−19,10,4,1,1,0,11,13,0,12,−1,1,−,1,−13,7,−6, −3,2,−1,0,−1,7,2,−5,4,0,0,0,−3,0,−4,3,1,−1,0,0},      {−6,−21,21,1,−2,−2,−1,−1,−6,−33,−25,−2,3,3,1,1,29,0,46,13,−4,0,−2,0,23,−28,−3,−44,7,−4,3,−1,50,27,0,27,15,−4,4,−1,7,29,−19, −4,−25,2,−3,0,0,−19,−4,9,10,7,−1,2,7,1,17,−8,−3,−5,−1,0},      {4,7,2,−6,2,0,1,0,1,21,2,−3,3,−2,0,−1,18,37,0,−12,4,−2,1,0,8,22,−36,−15,2,−5,0,−2,−16,−10,−62,−2,10,1,3,0,−7,−8, −21,61,16,2,3,0,10,−5,24,29,−30,−3,−4,−1,3,−9,7,−14,−13,8,−1,1},      {−2,−23,−7,2,1,1,0,0,−2,−45,−2,8,−3,0,−1,0,43,−20,10,11,0,3,1,1,71,3,18,1,−11,−1,−3,−1,4,−53,−9,−24,−2,1,0,1,−11, −15,27,10,17,−1,3,0,−2,15,6,−9,−8,−5,−0,−1,−4,1,−8,4,2,3,1,0},      {4,1,3,74,−16,8,−5,3,−1,−1,−31,−45,−14,6,−2,1,−1,10,39,−20,40,−7,4,−1,1,−35,−7,16,−5,−16,5,−4,1,29,−2,−2,−14,10,1,0,1,−3, −14,5,5,5,5,−5,2,−1,−1,8,2,−2,−5,0,1,−1,−3,0,−5,2,1,2,0,0},      {−9,−14,−17,−3,0,0,0,0,−19,−30,−31,−6,1,−1,−1,0,−29,−45,−35,−1,3,0,0,0,−34,−50,−26,12,8,2,2,1,−28,−33,2,27,8,4,2,2,−8, −6,23,30,4,2,1,0,−1,1,23,11,−8,−2,−2,−1,−1,0,11,−3,−7,1,−1,0},      {0,0,−2,8,−12,4,−2,2,−1,−2,2,−1,2,16,−5,3,−2,−2,−2,−5,13,−17,5,−2,2,3,−1,7,−14,21,−4,2,−2,−2,6,−11,15,−29,3,−3,1,6,−17,18, −43,43,0,4,0,−17,28,−34,60,−10,−18,4,−4,12,−16,23,−17,32,19,−4,3},      {1,4,−22,26,0,1,−2,0,−2,−8,28,−35,−2,0,1,0,9,−1,−23,28,10,−3,1,−1,−17,17,12,−18,−21,5,−2,1,24,−36,2,1,29,−2,2,0,−34,49,−6, −1,−19,−7,1,−2,15,−19,−25,17,4,11,−2,2,3,−7,3,7,−13,−7,−4,−1,−1},      {−6,−17,−75,−1,−11,−1,−4,0,5,18,−47,27,−15,−1,2,−4,43,34,35,−8,3−1,1,−29,−10,17,−15,−18,2,−4,0,3,−13,4,−17,4,2,0,1,9,−8,6, −1,7,−3,2,0,−6,−2,3,−1,−2,−1,1,0,−3,3,3,0,0,1,1,0,0},     }    },       {//2        {         {118,−36,−4,−5,−1,−2,0,−1,2,3,−4,−2,0,0,0,0,0,−18.5,1,1,0,0,0,0,−11,2,1,.0,0,0,0,0,−6.2,0,0,0,0,0,0,−3.1,0,0,0,0,0,0,       −2,1,0,0,0,0,0,0,−1.0,0,0,0,0,0,0},         {21,−3,−2,−1,0,0,0,0,−116,25,5,3,1,1,1,0,−32,1,3,0,1,0,0,0,23,−5,−1,0,0,0,0,0,12,−1,−1,0,0,0,0,0,5,       −1,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0},         {−21,1.4,−2,1,0,1,0,0,0,28,1,−2,0,−1,0,0,0,−118,17,6,2,2,1,1,0,−19,−23,0,1,0,0,0,17,−4,−1,0,0,0,0,0,6,−1,       −1,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0},         {−32,−106,48,−10,8,−2,3,−1,−6,−24,10,−1,1,0,0,0,−6,26,−9,2,−1,0,−1,0,5,8,−3,0,−1,0,0,0,6,−2,3,0,0,0,0,0,2,2,−1,0,0,0,0,0,1,2,       −1,0,0,0,0,0,0,1,0,0,0,0,0,0},         {5,2,−3,0,0,0,0,0,28,−10,−1,−1,0,0,0,0−12,−10,2,−1,1,0,0,0,119,−13,−7,−1,−20,−1,0,28,4,−30,−1,0,0,0,−9,2,1,0,0,0,0,0,       −4,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0},         {5,15,0,0,0,0,0,0,−20,−102,30,−8,5,−2,2,−1,−12,−55,10,−1,1,0,0,0,−10,20,−7,3,−1,1,0,0,19,−4,1,−1,0,0,0,3,5,       −2,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0},         {8,1,−1,−1,0,0,0,0,0,5,0,0,0,0,0,0,0,23,−3,0,−1,0,0,0,0,−24,−4,2,−1,0,0,0,0,117,−10,−7,−1,−2,0,−1,0,36,0,−4,0,1,0,0,0,11,0,       −1,0,0,0,0,0,0,0,0,0,0,0,0,0},         {−9,−32,9,−2,1,−1,1,0,11,51,−4,2,−1,1,0,0,−12,−99,19,−4,3,−1,1,0,−11,26,−2,1,0,0,0,0,−1,35,6,2,0,0,0,0,3,2,−1,1,0,0,0,0,1,       −2,0,−1,0,0,0,0,−1,2,0,0,0,0,0,0},         {15,−41,−91,20,−3,3,−4,2,−8,−24,−64,16,−1,2,−2,1,−1,−4,1,1,1,0,0,0,0,4,20,−6,1,−1,10,2,5,15,−4,0,0,0,0,1,3,6,−       1,0,0,0,0,0,2,2,0,0,0,0,0,0,0,1,0,0,0,0,0,0},         {2,0,−1,0,0,0,0,0,5,−1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,−1,0,0,0,0,0,0,−36,−8,3,0,1,0,0,0,8,118,−7,−8,0,−7,−8,0,−2,0,−1,0,21,4,−3,0,       −1,0,0,0,−9,0,1,0,0,0,0,0},         {0,6,−2,0,0,0,0,0,0,3,25,−6,0−1,0,0,0,0,12,−6,0,−2,0,−1,0,8,9,5,−14,−2,2,0,0,0,10,7,6,1,2,0,0,0,0,8,−8,4,1,0,0,0,0,2,−15,1,       −1,0,0,0,0,0,0,0,−1,0,0,0,0},         {3,23,66,−1,1,0,3,0,−7,−18,−82,17,−6,3,−4,1,−5,−17,−48,5,2,0,−1,0,1,1,30,−13,3,−1,1,−1,1,4,1,8,−60,−1,0,0,1,1,6,1,       −1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0},         {−2,0,1,0,0,0,0,0,−2,1,0,0,0,0,0,0,−1,0,0,0,0,0,0,−2,2,0,1,0,0,0,0,5,0,1,0,0,0,0,0,12,0,−1,1,−1,0,0,0,−95,4,5,0,2,0,1,0,       −85,1,6,−1,2,0,1,0},         {2,8,−2,0,1,0,0,0,−4,−17,4,0,−17,4,0,−1,0,0,0,5,39,−6,2,0,0,0,0−8,−75,5,−6,1,−2,0,0,1,89,−7,6,0,2,0,0,7,−4,2,2,0,0,0,0,0,−20,1,       −3,0,0,0,0,−2,5,−1,−1,0,0,0,0},         {−1,−4,−17,3,−1,0,−1,0,3,6,36,10,2,1,2,1,−6,−14,−77,11,−6,2,−3,1,−4,−9,−43,−26,−4,−3,−2,−2,5,−1,69,−16,1,−3,2,       −1,1,1,21,4,2,1,1,1,0,3,−3,2,−1,0,0,0,0,0,−3,0,0,0,0,0},         {2,−5,14,64,−58,23,−8,5,1,−1,1,0,22,−21,6,−1,1,0,4,1,−58,46,−17,6,−32,3,−11,−25,17,−6,1,−1,0,0,7,4,−7,0,−1,0,0,1,−1,1,       −1,0,0,0,0,−1,0,3,−1,1,0,0,0,0,0,1,0,0,0,0},         }, {   {−78,45,−8,5,−1,2,−1,1,75,−35,2,−3,0,−1,0,0,−33,7,4,−1,1,0,0,0,10,2,−3,0,0,,0,0,0,−4,−2,1,0,0,0,0,2,1,0,0,0,0,0,0, −2,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0},   {−82,9,8,1,2,0,1,0,−36,34,−10,3,−2,1,−1,0,68,−31,1,−1,0,0,0,0,−32,7,5,−1,1,0,0,0,11,3,−3,0,−1,0,0,0,−2,−2,0,0,0,0,0,3, −1,0,0,0,0,0,0,−1,0,1,0,0,0,0,0},   {18,−47,30,−7,5,−2,2,−1,77,32,−30,3,−4,0,−2,0,0,−43,12,0,1,0,0,0,−40,28,3,−1,1,1,0,1,0,20,−6,−5,1,−1,0,0,0,−10,1,3,0,0,0,0,0,4, −1,−1,0,0,0,0,0,−3,0,1,0,0,0,0,0},   {−46,−58,40,−9,6,−2,2,−1,−17,44,−23,2,−1,0,−1,0,−49,17,−5,7,−2,2,−1,1,53,−18,3,−2,−1,0,0,0,−21,1,3, −1,1,0,0,0,9,1,0,0,0,0,0,0,−4,1,0,0,0,0,0,0,−3,0,0,0,0,0,0,0},   {−6,27,−13,3,−1,1,−1,0,−45,12,−5,5,−3,1,−1,1,−68,−38,28,−6,5,−1,2,0,−2,55,−17,0,−1,−1,0,0,33,−34,−3,4,−2,1,−1,0,−19,97, −21,0,0,0,8,−1,−2,0,0,0,0,0,−3,1,0,0,0,0,0,0},   {21,−36,15,−4,2,−1,1,0,−14,−30,17,−6,4,−2,1,−1,−20,58,−25,7,−3,1,−1,0,−55,−12,7,1,−1,1,0,0,62,−9,0,−3,0,−1,0,0, −32,2,2,1,1,0,0,0,14,4,−2,0,−1,0,0,0,−6,−1,0,0,0,0,0,0}   {−7,−16,−53,28,−5,5,−3,2,12,42,59,−28,3,−4,3,−1,−20,−29,−54,15,1,1,1−1,0,2,2,38,2,−3,1,0,0,2,10,−14,8,2,−1,0,0,−3,−5,2,6, −1,1,0,0,2,2,−1,−3,0,0,0,0,0,−2,0,1,0,0,0,0},   {2.7,5,−3,0,−1,0,0,−20,−6,−10,4,−1,0,−1,0,−49,−15,8,−4,1,0,0,0,−72,−18,13,1,4,−1,1,0,−28,57,−6,0,−1,0,0,0,50,−17,−10,1,−2,1, −1,0,−21,−4,4,0,1,0,0,0,3,0,1,0,0,0,0,0},   {−21,−73,−30,6,−1,0,−1,0,−5,−44,42,−3,−1,0,1,0,12,−7,33,−18,7,−3,2,−1,−2,37,−36,4,0,−1,0,0,−26,−6,1,7,−2,2,0,1,24,4,1, −2,0,0,0,0,−10,−2,0,0,1,0,0,0,2,2,−1,0,0,0,0,0},   {0.4,−54,9,−3,1,−3,1,17,67,0,15,−5,4,0,1,−3,49,40,−15,0,−1,−1,−1,−26,−35,−39,−4,1,−1,−1,0,3,−17,8,9,0,1,1,0,6,2,5,−3,0,−1,0,0, −5,0,1,0,1,0,0,0,−1,1,−2,0,0,0,0,0},   {3,13,17,−4,2,0,1,0,1,11,−1,−6,2,−1,1,0,3,2,8,−41,19,−6,3,−2,1,−28,38,7,−7,−4,1,−1,0,−31,−74,17,−2,5−1,1,0,53,18,0,−1,0, −1,0,0,−26,−2,1,1,0,0,0,0,2,5,−2,0,0,0,0,0},   {−3,1,3,0,0,0,0,0,−5,−1,0,−1,0,0,0,0,−9,1,−3,0,0,0,0,0,−33,−2,−1,0,0,0,0,0,−87,−13,3,−1,1,0,0,0,−83,4,8,1,2,0,1,0,12,12,−2,−1, −1,0,0,0,4,−2,−2,0,0,0,0,0},   {0.−2,−5,5,−4,0,−1,0,−2,−6,−7,−5,6,0,2,0,4,10,24,33,−16,5,−2,2,2,2,2,23,−71,14,−71,14,−7,3,−2,−4,−4,59,48,10,−1,10,3,0,35,1,−23,4, −3,1,2,−3,−7,−15,13,0,1,0,−2,2,1,6,−2,−2,0,0},   {−2,2,−16,−56,54,−19,5,−4,3,0,21,58,−54,15,−3,3,−2,0,−21,23,19,1,−3,0,3,2,22,−9,10,−11,4,−2,−2,−4,−15,10,−11,6,−1,0,0,3,5, −2,3,0,−1,0,1,−2,−1,−1,−1,0,0,0,−1,1,0,0,1,−1,0,0},   {−1,−3,−4,0,0,−1,0,0,−1,−3,2,−3,1,0,0,0,−3,−9,2,7,−2,0,−1,0,−4,−16,6,−11,4,−1,1,0,−6,8,17,8,3,0,1,0,0,81,−33,−3,−80,−2,0,30, −75,0,4,1,2,−1,1,−18,21,14,−3,1,−1,1,0},   {6,25,74,5,2,2,4,0,6,24,84,−2,3,1,4,0,−2,−4,11,−14,5,−3,0,−1,−3,−9,−36,−8,1,−2,0,−1,0,3,−20,9,−1,1,0,0,3,2,2,1,−2,1,0,0,2,−5 −2,−1,2,0,0,0,1,2,−1,0,−1,0,0,0},  } }, { //3  {    {−113,26,13,3,3,1,1,0,40,−30,−2,0,0,0,0,0,13,4,−7,0,−1,0,0,0,1,0,1,−1,0,0,0,0,3,1 −1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}    {14,−55,14,0,2,0,1,0,85,10,−37,1,−5,0,−2,0,−35,5,0,7,−8,0,−2,0,−1,−7,−10,15,2,0,0,0,0,−5,2,−1,2,0,0,0,0,−1,2,2,0,0,0,0,0, −2,1,0,0,0,0,0,0,−1,−1,1,0,0,0,0,0},    {24,−34,18,−6,4,−2,1,−1,0,−81,9,14,0,4,0,2,34,14,−60,7,−3,1,−1,0,−14,40,−1,−20,2,−3,0,−1,2,0,1,0,0,−3,−1,1,0,−3,5,0,1,1, −1,0,0,0,0,1,−1,0,1,0,0,−1,2,0,0,0,0,0,0}    {−41,−94,30,6,5,2,2,1,−55,18,−22,4,1,1,0,0,10,−16,8,−5,1,0,0,0,16,−6,−14,6,−1,1,−1,0,1,9,−6,−5,2,0,0,0,3,0,0,−2, −1,0,0,0,1,2,0,−1,0,0,0,0,1,0,0,0,0,0,0,0,},    {−8,19,−3,−3,−1,0,0,0,−49,2,−38,8,0,2,0,1,10,59,−8,−42,5,−7,1,−3,0,−10,69,−15,−10,1,−2,0,9,−16,5,27,−11,3,−21,−41,2,8,3, −2,1,−1,2,−3,−1,3,1,0,1,0,−1,0,1,1,1,−1,0,0},    {10,22,59,13,4,−3,2,−1,−23,−50,3,25,−1,4,0,2,−64,2,2,−1,5,0,1,0,15,−47,−4,17,−1,2,0,1,−2,9,−34,−5,8,0,1,0,3,−1,5,−12, −8,1,0,0,0,3,−5,2,−1,−1,−1,0,1,0,1,−2,0,1,0,0},    {−14,−5,−6,−2,4,−1,1,0,−2,22,15,9,−5,3,−1,1,−70,−26,−43,7,16,0,4,0,26,12,5,−61,−4,1,−1,−1,3,−4,36,16,−29,−2,−4,0,3,2, −9,17,9,−5,0,−2,−2,−1,4,−2,1,3,1,0,2,0,−2,2,0,−2,1,0},    {9,−22,21,−16,1,−3,2,−1,23,−20,52,−21,3,−2,1,−1,25,−32,58,−8,−9,0,−1,0,26,−22,42,6,−21,4,−5,2,7,−13,3,48,−21,2,−4,2,−5,7, −33,36,+,−4,2,−1,−1,0,−4,4,4,−1,2,−1,−1,1,−5,4,3,−3,1,0},    {10,26,88,−24,4−4,2,−2,14,60,−1,29,−9,3,−2,1,39,−6,−20,8,10,−1,1,0,−14,10,0,−9,1,2,1,0,−3,−5,6,0,−2,−2,0,0,−1,−2,1,2,1,0, −1,0,0,−1,0,01,0,1,0,0,−1,−1,0,1,0,0,0,0},    {19,16,−5,14,−3,4,−1,1,24,−18,−69,15,11,0,2,0,23,−58,−4,−46,15,−2,2,−1,45,1,7,−9,−17,6,−5,2,−9,24,−4,3,−6,1,0,0,3,1,2,−1, −1,−1,1,−1,−2,2,0,−2,0,0,1,0,01,0,1,−1,−1,0,0,0},    {8,12,20,12,−4,−1,1,0,−9,−20,−26,−24,4,1,0,0,12,19,35,18,−8,−3,0,0,−16,−33,−39,−28,16,7,3,2,19,20,38,−16,−48,−8,−7,−2,−4, −2−1,45,19,−7,−3,−3,2,2,2−3,15,2,8,3,1,−1,−2,1,1,0,−1,−4,1,0},    {0,−13,−34,0,9,−2,0,0,10,9,19,22,−9,5,−1,0,33,0,−28,10,38,−3,6,0,−18,−73,−3,−33,1,18,0,5,5,7,−46,−2,23,−5,−2,−1,2,7,8, −15,2,−4,−2,−3,8,2,−3,3,−2,1,1,0,−2,2,3,−5,1,1,1,0},    {0,3,−2,12,1,−5,0,−1,−2,3,−8,7,6,2,−3,0,0,3,−4,20,4,−5,0,−3,1,7,−3,12,13,1,0,0,−7,17,−15,47,16,−11,4,−4,−6,−4,−24, −20,82,0,2,1,2,−14,3,−48,2,37,−6,7,−1,−1,−6,−5,−12,12,3,−2},    {−2,−54,12,−3,4,−1,1,0,−11,−26,6,11,−2,3,0,−20,−49,6,−13,5,3,0,1,−86,−4,7,1,−3,2,1,0,13,−56,−3,4,−1,1,0,1,−2,6,−32,0,−2,0, −1,0,2,−1,1,−10,0,−2,1,−1,−1,1,−3,0,−1,0,0−1,0},    {3,0,0,13,1,1,1,−2,3,−2,−8,11,16,3,−3,0,7,−3,4,27,11,−5,4,−6,24,−5,21,−3,74,1,1,1,1,−9,−1,−8,1,70,−3,12,−12,2,−31,2, −23,7,25,−2,−1,−8,−2,−16,1,−10,8,2,0,−1,−6,−4,−5,0,−1,2},    {3,0,15,84,−4,6,−4,4,3,2,41,42,56,−9,6,−2,0,23,25,−21,36,13,0,3,4,20,−6,−2,−13,20,2,2,6,−3,5,−3,−5,−5,7,−1,−2,2,3,2,−3, −1,0,1,0,0,1,2,−1,0,0,0,0,0,0,1,0,0,1,0},   }, {    {98,43,−1,−4,0,−1,0,−1,47,5,−12,1,−3,0,−1,0,28,34,−30,−1,0,0,0,−21,5,9,−1,1,0,0,0,−6,−2,4,1,0,0,0,0,−3,−1,1,1,0,0,0,0, −2,0,0,0,0,0,0,0,−2,0,1,0,0,0,0,0},    {−61,6,8,0,2,0,1,095,−34,−9,−1,−2,0,−1,0,7,36,−11,0,−2,0,−1,0,−25,9,12,2,2,0,1,0,0,−7,3,2,0,0,0,0,−3,0,0,1,0,0,0,0,0, −1,0,0,0,0,0,0,−1,0,0,0,0,0,0,0},    {−27,2,4,1,1,1,0,0,16,40,−11,1,−2,0,−1,0,−90,6,32,−2,5,−1,2,0,24,−58,3,6,0,1,0,1,133,−18,2,−1,0,−1,0,3,2,−2,−3,1,−1,0,0,1,1, −1,−1,0,0,0,0,2,−1,0,0,0,0,0,0},    {−13,−70,18,−1,4,0,1,0,28,−14,−6,0,0,0,0,0,−44,0,6,0,2,0,1,48,7,−49,3,−5,1,−2,0,−14,50,−1,−15,0,−3,0,−1,−2,2,14,−1, −1,0,0,0,−3,5,0,−1,0,0,0,0,0,0,3,0,−1,0,0,0},    {34,84,−25,3,−5,1,−2,0,44,−10,22,−7,3,−2,1,−1,−21,−48,4,7,0,2,0,1,15,17,−27,−1,−2,0,−1,0,−11,19,11,−80,−2,0,−1,0,−5,8,3, −1,0,0,0,−3,−1,−1,1,1,0,0,0,0,−1,0,0,0,0,0,0},    {22,6,8,−3,2,−1,1,0,−3,−72,16,3,3,1,1,0,8,−9,−2,2,0,1,0,0−4,−51,−2,14,−1,4,0,1,2,6,3,−62,4,−2,1,−1,0,−8,39,−8,−26,2,−4,1, −2,4,3,14,−7,−4,0,−1,0,2,4,3,1,−3,0,0,0},    {−8,−6,9,−2,2,−1,1,0,−35,−67,12,6,1,2,0,1,−73,13,−44,6,−2,1,1,0,15,32,3,−21,3,−4,1,−2,3,−7,27,−1,−1,1,0,0,06,−9,−1,8, −2,1,0,0,0,0,−5,2,1,0,0,0,2,0,−2,0,1,0,0,0},    {7,32,10,−3,−2,0,0,0,−21,−19,−37,4,−2,1,−1,0,12,60,12,−12,−2,−2,0,−1,5,−19,−15,8,2,1,1,0,4,59,5,−30,−2,−5,−1,−2,−12, −19,49,14,−2,1,0,1,4,−8,−17,7,2,1,0,1,−3,1,7,−1,0,−1,0,0},    {10,14,−2,−3,2,−1,0,0,9,−2,−8,4,−4,1,−1,0,18,24,−11,−18,1,−5,0,−2,91,6,52,1,−8,0,−2,0,−31,5,−10,40,5,5,1,2,−8,−4,−15,−14,9, −1,2,0,−1,−1,4,−2,−4,0,−1,0,0,2,−1,−1,1,0,0,0},    {11,−7,25,−2,2,−2,1,0,8,−32,16,−1,2,−2,,1,−1,16,−21,35,0,0,−1,0,0,1,1,−41,16,12,1,1,1,0,1,8,−26,29,12,−4,3,−1,1,4,−39,−13,53, −3,7,−1,3,−5,3,−53,16,13,0,3,0,−3,6,−15,−8,10,−2,1,0},    {6,2,−8,−1,−2,0,−1,0,12,15,−3,−7,−1,−20,−1,15,11,−12,2−4,0,−1,0,38,6,−3,−21,4,−5,1,291,−1,27,8,−10,0,3,0,1,50,0,30, −6,3,−1,1,−16,13,9,7,10,−2,3,0,−4,−6,0,1,5,1,1,1},    {12,28,101,−13,12,−3,5,−1,7,28,−11,29,−5,6,−2,2,4,−19,−45,3,4,0,1,0,−5,−10,−1,−17,3,−1,0,0,−1,−6,−3,−4,−3,1,−1,0,−2,2,0,−4, −2,−1,0,0,0,−1,2,0,−2,0,0,0,1,0,0,1,0,0,0,0},    {−2,−6,−4,−1,2,−1,1,0,4,4,13,−1,−4,1,−2,0,−2,−7,−7,−2,2,2,1,−1,2,3,18,−2,−7,0,−2,0,−4,−9,−18,−5,3,−4,1,−2,26,8,51,−19,−21,−1, −6,0,0,−4,3,87,−6,0,−1,0,−12,9,−40,−1,38,−2,6,0},    {8,12,24,3,−2,1,0,0,−5,−21,−44,−80,−3,−1,−1,1,14,46,3,−1,1,0,0,22,18,−28,13,6,3,2,1,−51,51,0,−30,−4,−3,−1,−1,40,26,−13,5, −10,−2,−3,−1,−19,26,3,4,−1,1,0,5,−19,−4,7,2,2,0,1},    {−1,−2,−13,−5,1,−2,0,−1,3,15,60,1,1,1,1,1,1,15,46,−24,48,2,6,1,2,26,−37,−36,−21,21,−1,40,−32,−24,−1,−30,−12,2,−2,1,−6,−6, −3,2,−9,−4,−1,−1,1,2,0,0,0,−1,−1,0,2,1,0,1,−1,0,0},    {2,−2,−47,24,−5,5,−2,2,5,−9,−69,27−2,4,−2,2,9,−30,−42,−9,14,−4,3,−2,2,−42,0,−36,14,−3,2,−1,−10,−24,5,−21,−5,4,3,1,−2,−11, −3,−1,−9,3,−2,0,2,−2,−8,2,−6,1,−1,0,2,3,−2,−1,−1,−1,0,−1}.   }  } };

TABLE 9 const int g_aiNsst4×4[4][2][16][16] = {  { //0   {    { 106,−48,−13,2,−45,21,6,−1,−10,6,1,−1,0,0 },    { 42,99,−55,−11,−2,−25,15,2,−12,−22,11,3,1,2,−1,0 },    { 31,−19,−9,4,101,−18,−29,1,−54,18,14,−2,−6,1,3,0 },    { −31,−37,−94,56,−4,−14,29,−10,6,18,18,−13,2,1,−4,1 },    { 7,−13,26, −8,−17,−105,36,22,−4,37,−25,−4,4,16,−5,−5 },    { −25,2,12,−2,−37,12,14,−2,−96,4,27,1,59,−9,−19,1 },    { 7,7,15,0,35,35,97,−40,−7,12,−43,12,−8,−14,−12,9 },    { 0,31,−9,−3,−12,20,−27,4,4,100,−25,−23,7,−48,23,9 },    { 17,28,43,106,−6,−10,−17,−28,−5,−13,−15,−24,3,5,4,4 },    { −9,−9,−32,2,−7,1,−25,9,−31,−28,−98,−32,15,7,39,−18 },    { −16,3,5,2,−28,3,10,3,−50,3,15,−4,−104,3,41,−2 },    { 3,6,5,23,14,31,30,107,−1,−10,−8,−38,2,−2,−5,−25 },    { −3,15,−6,−3,−5,29,−13,−6,−6,43,−15,−4,−10,104,−42,−17 },    { 4,8,11,31,1,5,7,15,11,29,32,98,4,−6,14,−57 },    { 3,0,8,−11,9,7,25,−16,10,3,25,−30,41,44,98,−17 },    { 0,−3,−2,−15,−1,−6,−5,−37,−2,−9,−5,−45,−7,−27,−21,−107 },   }   {    { −117,33,21,3,27,3,−5,−2,16,−3,−6,−1,4,−2,0,0 },    { −31,−94,33,14,−56,5,26,3,21,28,−6,−7,6,3,−5,−2 },    { 1,69,19,−15,−96,3,34,1,9,−17,−5,4,12,−1,−7,0 },    { 25,4,63,−9,21,90,−8,−26,15,−9,−40,0,−9,−16,1,7 },    { 18,4,91,−3,25,−74,13,17,−20,−11,−20,4,−1,11,−3,−4 },    { 7,−2,−2,−10,−25,−31,−89,6,68,−8,−38,10,−2,0,18,4 },    { 19,29,−8,4,27,−13,43,4,69,79,−16,−27,0,−5,−20,−6 },    { −3,19,23,−5,−22,9,−58,−5,−58,85,14,−20,13,8,6,−4 },    { 6,−16,−1,−111,7,−14,11,−47,7,12,19,24,−2,3,0,9 },    { 10,5,36,−2,6,22,−14,40,42,−6,100,11,−8,18,7,−19 },    { 4,7,14,41,−9,−26,−2,−87,13,−6,39,−33,−38,−22,24,28 },    { 8,−1,2,15,10,2,−5,−46,15,−17,5,−16,88,70,−17,−10 },    { −4,4,−8,−7,−4,10,14,0,−3,1,−23,−21,−61,87,53,−28 },    { −3,−6,−1,−23,−6,−2,−21,−1,−4,−27,2,−74,−32,−4,−78,−45 },    { 1,−5,0,−29,5,0,10,26,1,−17,1,−78,43,−36,72,−3 },    { 1,0,0,11,0,−6,4,−32,0,5,−4,33,10,−36,24,−110 },   }  },  { //1   {    { −108,41,4,3,48,11,−12,−1,6,−16,−5,2,3,−2,4,2 },    { −51,−29,15,−1,−87,44,21,−1,22,40,−15,−5,9,−6,−14,1 },    { 36,21,−2,−3,19,74,−31,−5,58,−18,−49,4,1,−40,−3,10 },    { −11,−91,27,0,50,−18,36,−6,50,−12,1,−11,1,−19,1,−3 },    { 12,28,−9,−2,45,−1,36,−8,0,85,−13,−26,15,−2,−61,−5 },    { 0,−40,31,−3,29,57,−5,−14,−82,5,−31,2,−32,25,−1,12 },    { −17,−49,−92,15,9,−5,−46,34,−5,24,−18,20,−3,−1,−11,10 },    { −7,0,13,−6,−17,−56,−4,−21,−36,−16,−67,3,25,−64,−18,35 },    { 7,−13,34,−2,9,−4,−45,−4,9,14,−10,23,95,54,4,6 },    { −2,4,43,−9,−6,−42,−52,−6,37,34,−22,20,−73,30,−15,9 },    { −3,−3,−24,−7,−14,−5,11,−16,11,−64,−32,−32,−3,59,−71,−17 },    { 3,15,−26,24,2,−10,56,−13,19,10,−53,6,−6,48,63,45 },    { −6,−9,−35,−85,0,1,−16,−77,4,13,16,−20,1,1,26,6 },    { 0,4,−2,55,5,9,39,23,4,−13,18,88,−2,5,−36,41 },    { 1,−4,−6,68,−2,9,−10,−71,5−5,47,16,−3,−4,−30,54 },    { 1,0,10,−22,0,4,−14,49,3,−5,24,−69,1,7,−6,88 },   },   {    { −85,56,−7,3,68,−31,−6,1,−13,−7,11,−1,3,5,−2,−1 },    { −61,−17,25,−1,−22,74,−31,0,46,−46,−7,10,−9,0,18,−5 },    { 50,−28,24,−5,70,−3,−33,,3,−6,−59,32,2,−27,33,6,−10 },    { −31,−75,44,−1,33,18,10,−17,−58,39,−27,8,18,−1,−4,7 },    { 19,−3,−34,20,47,6,36,−22,26,−17,−64,18,−6,−43,56,3 },    { 28,50,11,−8,−3,32,−59,4,−53,−1,−10,29,54,−29,29,−11 },    { 8,17,80,−44,5,−43,−19,2,49,31,−4,15,−21,−28,7,0 },    { −22,−38,3,4,−34,−63,8,−1,−6,−28,37,21,31,−13,62,−41 },    { 6,−27,−10,6,36,7,−11,20,52,11,35,−30,71,−52,−31,4 },    { 12,23,40,53,−5,−5,22,−77,20,−18,3,28,40,25,−33,−2 },    { 1,14,31,−45,−13,−5,49,9,−23,−64,−13,−43,31,−9,2,53 },    { 10,27,24,−19,18,47,59,5,9,35,34,−26,10,28,41,−53 },    { 0,10,27,47,−7,41,−1,−28,−26,3,46,−41,−52,−69,15,15 },    { −2,−2,−22,−63,5,18,31,−31,−11,−13,37,62,−19,−44,−40,−16 },    { −1,−5,−20,−28,4,4,−19,−45,18,32,41,40,9,28,51,79 },    { 3,7,23,42,5,10,35,74,2,5,26,67,−3,−1,5,45 },   }  },  { //2   {    { −110,47,−2,3,−36,15,0,1,16,−7,1,0,11,−4,0,0 },    { −32,11,−2,1,109,−41,0,−1,34,−12,−2,0,−13,5,−1,0 },    { 38,85,−73,17,12,28,−22,4,−8.−16,13,−3,−6,−7,6,−1 },    { 27,−9,−2,0,−20,9,−2,1,108,−37,−2,0,44,−15,−2,1 },    { 10,22,−15,5,−33,−87,65,−12,−12,−38,28,−5,3,8,−6,2 },    { −21,−59,−62,81,−8,−18,−20,24,3,13,14,−17,3,6,6,−7 },    { 3,−2,1,0,−25,6,0,1,41,−9,1,−1,−114,28,5,0 },    { 10,28,−17,1,−11,−26,12,−1,28,85,−51,6,15,51,−27,1 },    { 3,9,9,−9,−18,−49,−62,63,−14,−34,−47,44,−1,−3,−1,0 },    { 16,35,69,87,7,15,26,28,−3,−8,−20,−15,−3,−5,−10,−7 },    { 1,2,−14,5,−4,−18,25,−10,9,36,−39,14,−23,−100,38,0 },    { −8,−23,−32,15,9,32,35,−30,−15,−43,−57,46,−5,3,−54,32 },    { −2,−4,−10,−12,11,25,53,78,8,20,44,64,2,2,4,5 },    { 1,4,7,−5,−4,−13,−24,16,6,22,36,−23,−14,−45,−88,53 },    { 4,9,23,38,−5,−13,−32,−54,7,17,38,71,5,10,28,50 },    { −1,−1,−5,−9,2,4,14,28,−3,−7,−23,−43,7,18,50,100 },   },   {    { −97,43,−3,3,66,−23,−3,0,−15,0,5,−1,2,3,−2,0 },    { 61,34,−29,4,31,−58,22,−3,−62,35,0,−3,26,−6,−7,3 },    { −5,74,−47,9,54,−33,25,0,59,−6,−2,−5,−21,4,−1,2 },    { 49,0,2,−3,77,−13,−10,2,48,−34,11,−2,−61,22,1,−1 },    { −16,−49,−12,18,17,−15,54,−26,27,57,−55,11,−31,−29,18,3 },    { 2,18,72,−54,−14,−45,−34,32,19,48,−11,−3,−14,−19,11,−2 },    { 17,14,−3,1,37,19,−8,2,64,1,−11,3,90,−40,9,−2 },    { 15,53,−15,4,9,68,−29,4,−28,17,−26,12,−42,−51,36,−7 },    { −9,−26,−45,−15,7,14,−4,47,9,35,52,−57,−15,−40,−34,25 },    { −3,−4,−27,−77,8,15,45,54,−12,−29,−46,−7,9,24,22,−6 },    { −7,−28,−14,5,−12,−52,−10,7,−13,−61,17,0,−4,−68,56,−18 },    { 5,24,52,−22,2,15,67,−30,−9,−37,12,−9,−10,−52,−43,26 },    { 4,9,28,47,−1,−3,−2,14,−6,−15,−40,−83,6,15,34,54 },    { 2,10,23,0,4,21,49,−8,5,30,68,−22,5,23,71,−35 },    { 2,4,27,62,1,2,28,78,−2,−5,−11,10,−4,−9,−31,−60 },    { 0,0,7,19,1,1,16,47,1,3,27,72,1,5,26,83 },   }  },  { //3   {    { 113,−39,−3,−2,23,22,−12,1,−21,18,3,−2,5,0,4,0 },    { 21,41,−17,2,−84,59,13,−6,−20,−32,34,−3,11,−21,1,6 },    { −35,26,−19,2,46,53,−33,−5,−46,59,26,−18,−6,−21,32,1 },    { 29,80,−43,4,56,−1,31,−18,42,−19,10,8,−11,20,−8,6 },    { 13,31,−31,7,−49,−5,−39,11,23,50,−60,−13,−14,41,19,−32 },    { 12,45,21,−6,−4,−47,45,9,−84,14,−30,23,−22,−12,0,−8 },    { −10,−18,−77,37,13,−12,−37,10,−46,−48,−21,0,7,−5,−43,−10 },    { 19,16,−14,8,−8,−72,−22,−2,10,−2,27,−45,39,−55,49,2 },    { 9,36,44,−11,26,29,−29,40,6,−19,−44,11,72,−23,−16,−20 },    { 7,26,41,10,3,−6,−55,48,5,−36,20,−18,−79,−5,−6,13 },    { −5,−12,5,−22,16,16,20,−17,−10,−49,−7,−38,−19,9,42,−91 },    { −3,−17,−22,42,2,15,24,46,27,−2,−13,65,−21,−47,54,−13 },    { 1,1,18,77,2,−2,33,48,−9,17,39,−32,28,50,−7,−21 },    { −2,1,−15,−45,0,−16,−27,31,−23,−23,37,48,26,65,49,11 },    { 2,6,35,62,5,8,−21,−64,−15,−32,−33,10,7,25,48,35 },    { 5,11,21,22,−8,−20,−38,−45,6,18,47,60,0,−9,−30,−65 },   },   {    { −96,34,1,3,67,−31,−1,−2,−20,14,0,0,6,−3,0,0 },    { −19,−87,29,2,38,60,−38,−3,−18,−5,24,0,4,−4,−6,2 },    { 69,23,−20,1,58,1,5,−2,−78,17,13,1,24,−15,−5,2 },    { −28,26,−38,13,−19,54,33,−15,−26,−77,21,15,20,14,−30,−3 },    { 4,42,74,−35,−20,−9,−51,36,−23,−37,20,−17,21,15,−12,1 },    { −27,−36,2,8,−63,−28,12,−3,−51,26,−16,−1,71,−29,−1,−1 },    { 10,−32,19,−13,29,−21,31,12,−12,−41,−76,13,14,58,15,−28 },    { 11,−29,−32,26,9,−64,−29,−18,19,−18,44,−16,26,54,−39,18 },    { −11,−22,−53,−83,3,2,19,66,3,6,14,−30,1,1,−14,8 },    { −8,19,−45,13,−10,33,−55,2,−6,10,−18,−37,24,42,74,0 },    { −13,−17,−11,5,−32,−27,−10,−2,−71,−10,7,−4,−91,18,11,−1 },    { −2,3,−16,−50,−9,−7,−27,−27,2,19,30,86,9,18,15,−52 },    { −2,−2,35,−19,−4,6,60,−21,−5,19,46,5,8,46,48,60 },    { 6,−16,−11,−17,14,−38,−7,−15,11,−70,14,2,6,−64,64,17 },    { −1,6,−9,−51,−3,8,−32,−62,−5,0,−55,6,−5,−2,−33,67 },    { −1,0,−13,34,−1,−1,−20,69,−1,−2,−13,76,2,2,3,63 },   }  } };

All of the illustrative transform kernel matrices shown in Table 8 are transform kernel matrices multiplied by 128 as a scaling value. In a g_aiNsst8×8[N1][N2][16][64] array present in matrix arrays of Table 8, N1 denotes the number of transform sets (N1 is 4 or 35, distinguished by index 0, 1, . . . , and N1−1), N2 denotes the number (1 or 2) of transform kernel matrices included in each transform set, and [16][64] denotes a 16×64 reduced secondary transform (RST).

As shown in Table 3 and Table 4, when a transform set includes one transform kernel matrix, either a first transform kernel matrix or a second transform kernel matrix may be used for the transform set in Table 8.

While 16 transform coefficients are output when the RST is applied, only m transform coefficients may be output when only an m×64 portion of a 16×64 matrix is applied. For example, when only eight transform coefficients are output by setting m=8 and multiplying only an 8×64 matrix from the top, it is possible to reduce computational amount by half. To reduce computational amount in a worst case, an 8×64 matrix may be applied to an 8×8 transform unit (TU).

An m×64 transform matrix applicable to an 8×8 region (m≤16, e.g., the transform kernel matrices in Table 8) receives 64 pieces of data and generates m coefficients. That is, as shown in Equation 5, when the 64 pieces of data form a 64×1 vector, an m×1 vector is generated by sequentially multiplying an m×64 matrix and a 64×1 vector. Here, the 64 pieces of data forming the 8×8 region may be properly arranged to form a 64×1 vector. For example, as shown in Table 10, the data may be arranged in the order of indexes indicated at respective positions in the 8×8 region.

TABLE 10 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

As shown in Table 10, the data is arranged in the row-first direction in the 8×8 region for a secondary transform. This order refers to an order in which two-dimensional data is one-dimensionally arranged for a secondary transform, specifically an RST or an LFNST, and may be applied to a forward secondary transform performed in an encoding apparatus. Accordingly, in an inverse secondary transform performed by the inverse transformer of the encoding apparatus or the inverse transformer of the decoding apparatus, transform coefficients generated as a result of the transform, that is, primary transform coefficients, may be two-dimensionally arranged as shown in Table 10.

When there are 67 intra prediction modes as shown in FIG. 5, all directional modes (mode 2 to mode 66) are symmetrically configured about mode 34. That is, mode (2+n) is symmetric to mode (66−n) (0≤n≤31) about mode 34 in terms of prediction direction. Therefore, if a data arrangement order for configuring a 64×1 input vector for mode (2+n), that is, modes 2 to 33, corresponds to the row-first direction as shown in Table 10, a 64×1 input vector for mode (66−n) may be configured in an order shown in Table 11.

TABLE 11 1 9 17 25 33 41 49 57 2 10 18 26 34 42 50 58 3 11 19 27 35 43 51 59 4 12 20 28 36 44 52 60 5 13 21 29 37 45 53 61 6 14 22 30 38 46 54 62 7 15 23 31 39 47 55 63 8 16 24 32 40 48 56 64

As shown in Table 11, the data is arranged in the column-first direction in the 8×8 region for a secondary transform. This order refers to an order in which two-dimensional data is one-dimensionally arranged for a secondary transform, specifically an RST or an LFNST, and may be applied to a forward secondary transform performed in an encoding apparatus. Accordingly, in an inverse secondary transform performed by the inverse transformer of the encoding apparatus or the inverse transformer of the decoding apparatus, transform coefficients generated as a result of the transform, that is, primary transform coefficients, may be two-dimensionally arranged as shown in Table 11.

Table 11 shows that, for intra prediction mode (66−n), that is, for modes 35 to 66, a 64×1 input vector may be configured for according to the column-first direction.

In summary, the same transform kernel matrix shown in Table 8 may be applied while symmetrically arranging input data for mode (2+n) according to the row-first direction and input data for mode (66−n) (0≤n≤31) according to the column-first direction. A transform kernel matrix to be applied in each mode is shown in Table 5 to Table 7. Here, either the arrangement order shown in Table 10 or the arrangement order shown in Table 11 may be applied for the planar mode of intra prediction mode 0, the DC mode of intra prediction mode 1, and intra prediction mode 34. For example, for intra prediction mode 34, input data may be arranged according to the row-first direction as shown in Table 10.

According to another example, all of the illustrative transform kernel matrices shown in Table 9 applicable to a 4×4 region are transform kernel matrices multiplied by 128 as a scaling value. In a g_aiNsst4×4[N1][N2][16][64] array present in matrix arrays of Table 9, N1 denotes the number of transform sets (N1 is 4 or 35, distinguished by index 0, 1, . . . , and N1−1), N2 denotes the number (1 or 2) of transform kernel matrices included in each transform set, and [16][16] denotes a 16×16 transform.

As shown in Table 3 and Table 4, when a transform set includes one transform kernel matrix, either a first transform kernel matrix or a second transform kernel matrix may be used for the transform set in Table 9.

As in the 8×8 RST, only m transform coefficients may be output when only an m×16 portion of a 16×16 matrix is applied. For example, when only eight transform coefficients are output by setting m=8 and multiplying only an 8×16 matrix from the top, it is possible to reduce computational amount by half. To reduce computational amount in a worst case, an 8×16 matrix may be applied to a 4×4 transform unit (TU).

Basically, the transform kernel matrices applicable to a 4×4 region, presented in Table 9, may be applied to a 4×4 TU, a 4×M TU, and an M×4 TU(M>4, the 4×M TU and the M×4 TU may be divided into 4×4 regions, to which each designated transform kernel matrix may be applied, or the transform kernel matrices may be applied only to a maximum top-left 4×8 or 8×4 region) or may be applied only to a top-left 4×4 region. If the secondary transform is configured to be applied only to the top-left 4×4 region, the transform kernel matrices applicable to an 8×8 region, shown in Table 8, may be unnecessary.

An m×16 transform matrix applicable to a 4×4 region (m≤16, e.g., the transform kernel matrices in Table 9) receives 16 pieces of data and generates m coefficients. That is, when the 16 pieces of data form a 16×1 vector, an m×1 vector is generated by sequentially multiplying an m×16 matrix and a 16×1 vector. Here, the 16 pieces of data forming the 4×4 region may be properly arranged to form a 16×1 vector. For example, as shown in Table 12, the data may be arranged in the order of indexes indicated at respective positions in the 4×4 region.

TABLE 12 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

As shown in Table 12, the data is arranged in the row-first direction in the 4×4 region for a secondary transform. This order refers to an order in which two-dimensional data is one-dimensionally arranged for a secondary transform, specifically an RST or an LFNST, and may be applied to a forward secondary transform performed in an encoding apparatus. Accordingly, in an inverse secondary transform performed by the inverse transformer of the encoding apparatus or the inverse transformer of the decoding apparatus, transform coefficients generated as a result of the transform, that is, primary transform coefficients, may be two-dimensionally arranged as shown in Table 12.

When there are 67 intra prediction modes as shown in FIG. 5, all directional modes (mode 2 to mode 66) are symmetrically configured about mode 34. That is, mode (2+n) is symmetric to mode (66−n) (0≤n≤31) about mode 34 in terms of prediction direction. Therefore, if a data arrangement order for configuring a 16×1 input vector for mode (2+n), that is, modes 2 to 33, corresponds to the row-first direction as shown in Table 12, a 64×1 input vector for mode (66−n) may be configured in an order shown in Table 13.

TABLE 13 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16

As shown in Table 13, the data is arranged in the column-first direction in the 4×4 region for a secondary transform. This order refers to an order in which two-dimensional data is one-dimensionally arranged for a secondary transform, specifically an RST or an LFNST, and may be applied to a forward secondary transform performed in an encoding apparatus. Accordingly, in an inverse secondary transform performed by the inverse transformer of the encoding apparatus or the inverse transformer of the decoding apparatus, transform coefficients generated as a result of the transform, that is, primary transform coefficients, may be two-dimensionally arranged as shown in Table 13.

Table 13 shows that, for intra prediction mode (66−n), that is, for modes 35 to 66, a 16×1 input vector may be configured for according to the column-first direction.

In summary, the same transform kernel matrices shown in Table 9 may be applied while symmetrically arranging input data for mode (2+n) according to the row-first direction and input data for mode (66−n) (0≤n≤31) according to the column-first direction. A transform kernel matrix to be applied in each mode is shown in Table 5 to Table 7. Here, either the arrangement order shown in Table 12 or the arrangement order shown in Table 13 may be applied for the planar mode of intra prediction mode 0, the DC mode of intra prediction mode 1, and intra prediction mode 34. For example, for intra prediction mode 34, input data may be arranged according to the row-first direction as shown in Table 12.

On the other hand, according to another embodiment of this document, for 64 pieces of data forming an 8×8 region, not the maximum 16×64 transform kernel matrix in Tables 8 and 9, but a maximum of 16×48 kernel matrix can be applied by selecting only 48 pieces of data. Here, “maximum” means that the maximum value of m is 16 for an m×48 transform kernel matrix capable of generating m coefficients.

A 16×48 transform kernel matrix according to the present embodiment may be represented as shown in Table 14.

TABLE 14 const int g_aiNsst8×8[4][2][16][48] = {  { //0   {    { −117,28,18,2,4,1,2,1,32,−18,−2,0,−1,0,0,0,4,−1,−3,0,−1,0,0,0,2,0,0,0,0,0,0,0,3,0,−1,0,1,0,0,0,1,0,0,0,1,0,0,0 },    { −29,−91,47,1,9,0,3,0,−54,26,−8,3,0,1,0,0,33,5,−9,−1,−2,0,−1,0,−3,3,0,0,0,0,0,0,7,2,−2,0,−1,1,0,0,2,1,−1,0,0,0,0,0 },    { −10,62,−11,−8,−2,−2,−1,−1,−95,3,32,0,4,0,2,0,32,−30,−4,4,−1,1,0,0,6,2,−5,0,0,0,0,0,6,−3,0,0,2,0,−1,0,2,−1,0,0,1,0,0,0 },    { −15,15,−10,−2,1,0,1,0,10,112,−20,−17,−4,−4,−1,−2,−20,−26,31,1,0,0,0,0,2,−16,−1,6,0,1,0,0,1,−4,0,0,0,−3,0,1,0,−1,0,0,0,− 2,0,0 },    { 32,39,92,−44,4,−10,1,−4,26,12,−15,13,−5,2,−2,0,29,−16,−22,8,0,1,0,1,−20,6,4,−3,1,0,0,0,1,−4,−3,2,−4,1,0,0,1,−1,−2,1,− 2,0,0,0 },    { −10,1,50,−15,2,−3,1,−1,−28,−15,14,6,1,1,1,0,−99,−4,9,5,5,2,2,1,44,−10,−11,1,−2,0,−1,0,−5,4,−3,0,8,−1,−2,0,−2,1,−1,0,4,0,− 1,0 },    {1,−33,−11,−14,7,−2,2,0,29,−12,37,−7,−4,0,−1,0,6,−99,3,26,−1,5,0,2,14,30,−27,−2,1,−1,0,−1,−6,6,6,−3,1,3,−3,0,−1,1,1,0,0,1,− 1,0 },    { 0,6,−6,21,−4,2,0,0,−20,−24,−104,30,5,5,1,2,−7,−46,10,−14,7,0,1,0,9,21,7,−6,−2,−1,0,−1,2,2,5,−2,0,3,4,−1,0,0,1,0,0,1,2,−1 },    { −13,−13,−37,−101,29,−11,8,−3,−12,−15,−20,2,−11,5,−2,1,−12,10,26,12,−6,0,−1,0,−32,−2,11,3,3,−1,1,0,11,−5,−1,6,−4,2,1,0,3,− 1,1,2,−1,0,0,0 },    { 6,1,−14,−36,9,−3,2,0,10,9,−18,−1,−3,1,0,0,38,26,−13,−1,−5,−1,−1,0,102,3,−14,−1,−5,−1,−2,0,−29,10,10,0,10,−4,−1,1,− 7,1,2,1,2,−1,0,0 },    { −12,−2,−26,−12,−9,2,−1,1,−3,30,4,34,−4,0,−1,0,−30,3,−92,14,19,0,3,0,−11,34,21,−33,1,−2,0,−1,−9,−4,18,3,2,0,0,−2,−1,− 1,3,0,0,0,0,−1 },    { 0,−3,0,−4,−15,6,−3,1,−7,−15,−28,−86,19,−5,4,−1,−5,−17,−41,42,−6,2,−1,1,−1,−40,37,13,−4,2,−1,1,−10,13,−1,−4,4,−4,3,4,−2,2,−1,− 1,1,−1,1,2 },    { −1,9,13,5,14,−2,2,−1,−8,3,−4,−62,4,1,1,0,−12,26,16,−11,−17,0,−1,0,−11,97,−3,−3,0,−6,0,−2,−21,−5,23,0,2,−2,−1,6,−3,− 3,1,0,0,0,0,2 },    { 6,2,−3,2,10,−1,2,0,8,3,−1,−20,0,1,0,0,−4,4,−16,0,−2,0,1,0,34,23,6,−7,−4,−2,−1,0,103,−5,−30,6,−27,10,7,−2,11,−3,−1,1,− 4,1,0,1 },    { 6,9,−2,35,110,−22,11,−4,−2,0,−3,1,−18,12,−3,2,−5,−4,−22,8,−25,3,0,0,−3,−21,2,−3,9,−2,1,0,−7,1,3,−5,3,0,−1,0,0,1,0,− 1,1,0,0,0 },    { −1,7,−2,9,−11,5,−1,1,−7,2,−22,4,−13,0,−1,0,0,28,0,76,4,−6,0,−2,−13,5,−76,−4,33,−1,3,0,9,18,−3,−35,−4,−1,6,1,1,2,0,−3,− 1,0,2,0 },   },   {    { −108,48,9,1,1,1,0,0,44,−6,−9,−1,−1,0,−1,0,9,−9,−1,1,0,0,0,0,3,−1,1,0,0,0,0,0,1,−1,0,0,1,0,0,0,0,−1,0,0,0,0,0,0 },    { 55,66,−37,−5,−6,−1,−2,0,67,−30,−20,4,−2,0,−1,0,−31,−19,14,4,1,1,1,0,−6,3,5,−2,0,0,0,0,−7,−1,1,0,−1,1,1,0,−2,−1,1,0,0,0,0,0 },    { 2,86,−21,−13,−4,−2,−1,−1,−88,5,6,4,5,1,1,0,14,−5,0,3,0,0,0,0,10,−5,−2,0,−1,0,0,0,6,−5,0,1,2,−1,0,0,1,−1,0,0,1,0,0,0 },    { −24,−21,−38,19,0,4,−1,2,−23,−89,31,20,2,3,1,1,−30,26,36,−8,−2,−2,0,−1,14,18,−7,−9,−1,−1,0,0,1,3,−2,−1,3,2,−2,−1,0,1,0,0,1,1,− 1.0 },    { 9,20,98,−26,−3,−5,0,−2,−9,−26,15,−16,2,0,1,0,−61,−3,−2,3,7,1,1,0,12,16,−6,−1,0,−1,0,0,2,0,−8,1,3,1,−1,1,0,−1,−2,0,1,0,−1,0 },    { −21,−7,−37,10,2,2,−1,1,−10,69,−5,−7,−2,−2,0,−1,−93,2,19,0,3,0,2,0,17,4,0,0,−1,0,0,0,5,−4,−2,0,4,−2,0,1,0,0,0,0,2,−1,0,0 },    { −10,−25,4,−17,8,−2,2,−1,−27,−17,−71,25,8,2,1,1,−4,−66,28,36,−5,3,0,1,−10,20,33,−13,−8,0,0,−1,3,6,−3,−7,−1,3,3,−1,1,0,− 1,0,0,1,1,−1 },    { 2,5,10,64,−9,4,−3,1,−4,8,62,3,−17,1,−2,0,−3,−75,5,−14,1,4,0,1,−36,6,18,−4,4,0,1,0,1,14,−2,−8,−2,1,−3,0,2,2,−1,−2,0,1,−1,0 },    { −11,−15,−28,−97,6,−1,4,−1,7,3,57,−15,10,−2,0,−1,−1,−27,13,6,1,−1,0,0,−34,−6,0,3,4,1,2,0,−2,8,1,5,−2,0,−3,1,1,1,0,2,−1,0,− 1.0 },    { 9,13,24,−6,7,−2,1,−1,16,39,20,47,−2,−2,−2,0,28,23,76,−5,−25,−3,−3,−1,6,36,−7,−39,−4,−1,0,−1,2,−4,−18,−3,−1,−1,−2,−2,1,−2,− 2,0,0,0,−1,−1 },    { −7,11,12,7,2,−1,0,−1,−14,−1,−24,11,2,0,0,0,−20,48,11,−13,−5,−2,0,−1,−105,−19,17,0,6,2,3,0,−14,8,8,2,1,2,−1,−2,3,0,− 1,0,0,0,0,0 },    { 0,0,7,−6,23,−3,3,−1,5,1,18,96,13,−9,−1,−1,−21,−7,−42,14,−24,−3,0,0,11,−47,−7,3,−5,9,1,2,0,−1,19,−1,1,0,−1,−6,−1,1,2,0,1,0,0,− 2 },    { −2,−6,−1,−10,0,1,1,0,−7,−2,−28,20,−15,4,−3,1,−2,−32,−2,−66,3,7,1,2,−11,13,−70,5,43,−2,3,0,8,−14,−3,43,−1,2,7,−1,1,−2,1,3,− 1,1,1,0 },    { −1,6,−16,0,24,−3,1,−1,2,6,6,16,18,−7,1,−1,−3,11,−63,9,4,−5,2,−1,−22,94,−4,−6,−4,−4,1,−2,10,23,−19,−5,0,−6,−4,6,3,−2,1,1,0,− 1,0,0 },    { −5,−6,−3,−19,−104,18,−4,3,0,6,0,35,−41,20,−2,2,−2,10,−18,16,21,3,−2,0,−2,11,6,−10,6,−3,−1,0,−1,5,−1,−6,−1,−1,−1,−1,− 1,0,0,0,0,0,0,−1 },    { −1,−2,0,23,−9,0,−2,0,1,1,8,−1,29,1,1,0,3,−6,13,76,30,−11,−1,−2,−26,−8,−69,7,−9,−7,3,−1,−10,−34,−25,13,−1,0,11,5,1,−1,1,− 2,0,0,2,0 },   }  },  { //1   {    { 110,−49,−3,−4,−1,−1,0,−1,−38,−1,10,0,2,0,1,0,−9,13,1,−2,0,0,0,0,−4,2,−3,0,0,0,0,0,−2,2,0,1,−1,1,0,0,−1,1,0,0,−1,0,0,0 },    { −43,−19,17,−1,3,0,1,0,−98,46,14,−1,2,0,1,0,26,26,−15,−3,−2,−1,−1,0,11,−7,−9,2,0,0,0,0,9,−3,−1,2,3,−3,0,0,4,−1,0,0,2,−1,0,0 },    { −19,17,−7,3,−2,1,−1,0,−32,−59,29,3,4,0,2,0,−72,43,34,−9,3,−2,1,−1,13,36,−18,−10,0,−2,0,−1,3,0,−12,3,6,1,−3,2,1,−1,−2,0,3,1,− 1,1 },    { −35,−103,39,1,7,0,2,0,38,−13,25,−6,1,−1,0,0,−1,7,6,−7,1,−1,0,0,−13,14,2,−4,2,−1,0,0,−2,11,−6,−2,−2,4,−3,0,0,3,−2,0,−1,1,− 1,0 },    { 9,5,−6,−1,−1,0,−1,0,42,4,21,−11,1,−3,1,−1,21,70,−32,−21,0,−4,−1,−1,34,−26,−57,11,4,2,0,1,−4,−32,5,24,1,−6,12,4,−3,−2,4,− 2,0,−1,0,0 },    { −5,−5,−28,9,−3,2,−1,1,−20,−78,22,16,1,3,0,1,80,−6,25,−5,−4,−1,−1,0,6,−24,7,−9,0,0,0,0,−7,3,13,−4,−3,5,1,−5,−2,3,1,−2,−1,2,−1,− 2 },    { 14,17,27,−12,1,−3,1,−1,8,19,−13,4,−2,1,−1,0,48,−1,48,−15,−4,−2,−1,−1,1,60,−28,−42,5,−6,1,−2,11,−11,−51,11,−2,−10,−2,13,2,− 6,−4,4,−2,−3,2,2 },    { 7,35,17,−4,−1,0,0,0,3,8,54,−17,1,−2,1,−1,10,14,−11,−34,4,−4,1,−1,−80,−7,−6,2,15,0,3,0,−16.46.1.3.2.7,−24,0,2,−2,−5,8,1,−1,− 2,2 },    { −13,−27,−101,24,−8,6,−3,2,11,43,6,29,−6,3,−1,1,−3,14,21,−12,−7,−2,−1,−1,−23,10,−4,−12,3,0,1,0,2,9,−10,0,1,−5,−4,4,2,− 2,2,2,0,−2,1,0 },    { −11,−13,−3,−10,3,−1,1,0,−19,−19,−37,8,4,2,0,1,−12,−30,3,−9,5,0,1,0,−56,−9,−47,8,21,1,4,1,−11,−30,10,59,−2,8,41,8,2,5,6,−7,− 1,3,5,−2 },    { −4,−10,−24,−11,3,−2,0,−1,−6,−37,−45,−17,8,−2,2,−1,17,14,−58,14,15,0,2,0,−10,34,−7,28,4,−1,1,0,23,34,−31,4,10,−22,− 30,22,4,−15,9,20,2,−5,9,4 },    { −2,1,13,−17,3,−5,1,−2,3,0,−55,22,6,1,1,0,8,74,21,40,−14,0,−2,0,−36,−8,11,−13,−23,1,−3,0,−36,6,16,−14,2,19,−4,−12,−1,0,−7,− 3,0,2,−2,−1 },    { 3,1,5,−15,1,−2,1,−1,7,4,−7,29,−1,2,−1,1,8,3,12,−14,−9,−1,−1,0,4,29,−15,31,10,4,1,1,61,22,55,14,13,3,−9,−65,1,−11,−21,− 7,0,0,−1,3 },    { −4,−8,−1,−50,6,−4,2,−2,−1,5,−22,20,6,1,0,0,−16,−15,18,−29,−11,2,−2,1,40,−45,−19,−22,31,2,4,1,−25,41,0,12,9,7,−42,12,−3,− 14,2,28,5,1,6,2 },    { 5,−1,26,102,−13,12,−4,4,−4,−2,−40,−7,−23,3,−5,1,−1,5,8,−23,7,2,1,1,10,−11,−13,−3,12,−3,2,0,−9,23,4,9,14,9,−14,−4,0,−12,− 7,6,3,0,6,3 },    { −5,−6,−27,−22,−12,0,−3,0,−5,8,−20,−83,0,0,0,0,9,7,24,−20,41,3,6,1,15,20,12,11,17,−9,1,−2,−26,−1,18,−1,−12,32,3,−18,−5,10,− 25,−5,−2,1,−8,10 },   },   {    {    { 80,−49,6,−4,1,−1,1,−1,−72,36,4,0,1,0,0,0,26,0,−12,2,−2,1,−1,0,−7,−9,6,1,0,0,0,0,3,5,−1,−2,−2,−2,−1,1,1,1,0,0,−1,−1,0,0 },    { −72,−6,17,0,3,0,1,0,−23,58,−21,2,−3,1,−1,0,55,−46,−1,6,−2,1,−1,0,−22,7,17,−7,2,−1,1,0,9,5,−12,1,−3,−4,4,2,4,1,−2,−1,−1,− 1,1,0 },    { −50,19,−15,4−1,1−1,1−58−2,30−3,4−1,2,0,6,57,−34,0,−2,0,−1,0,34,−48,−2,14,−4,3,−1,1,−10,7,21,−10,6,1,−11,0,−1,− 1,4,2,3,0,−2,−1 },    { −33,−43,28,−7,4,−2,2,−1,−38,11,−8,4,1,1,0,0,−55,24,26,−5,2,−1,1,0,15,46,−40,−1,−1,0,−1,0,17,−38,1,17,− 10,1,0,1,3,2 },    { 10,66,−21,−3,−3,0,−1,0,−53,−41,−2,16,−1,4,−1,1,36,−5,41,−20,3,−3,1,−1,−30,26,−32,−3,7,−2,2,−1,15,−8,1,17,−1,−2,4,−8,2,0,− 1,3,0,0,0,−1 },    { 18,14,13,−9,2,−2,1,−1,34,32,−31,12,−5,2,−2,1,40,4,−4,−9,−3,−2,−1,−1,27,−31,−43,19,−2,3,−1,1,7,−49,52,10,−11,22,7,−26,−1,− 6,−9,6,−2,2,4,−2 },    { 21,66,−1,9,−4,2,−1,1,−21,41,−30,−10,0,−2,0,−1,−35,−17,−3,26,−6,5,−2,2,56,3,18,−25,−1,−2,−1,−1,−15,−13,−27,9,9,−6,20,5,−3,2,− 6,−9,3,−3,1,5 },    { 1,−6,−24,17,−5,3,−2,1,24,10,39,−21,5,−4,2,−1,33,32,−30,4,−3,−1,−1,0,−4,13,−16,−10,0,−1,0,0,24,−26,−37,33,5,−32,55,−5,− 7,22,−14,−22,1,−9,−3,13 },    { 9,33,−24,1,4,0,1,0,6,50,26,1,−10,0,−22,0,−27,1,−28,−21,16,−5,3,−2,−23,36,−2,40,−17,4,−3,1,43,−13,4,−41,−19,−2,−24,17,11,− 4,8,4,−3,−3,−3,−3 },    { −7,−9,−32,14,−3,3,−1,1,−23,−28,0,−5,−1,0,0,0,−36,−59,−24,14,4,2,1,1,−23,−26,23,26,−3,5,0,2,10,−26,38,7,−12,11,42,−22,− 5,20,−14,−15,−1,−2,1,6 },    { 6,30,69,−18,5,−4,3,−1,−3,−11,−34,−16,9,−4,2,−1,−16,35,−35,30,−9,3,−2,1,−57,−13,6,4,−5,5,−1,1,28,10,4,7,0,−15,7,−10,−1,7,− 2,2,1,−3,0,0 },    { 1,−8,24,−3,7,−2,2,−1,−6,−51,−6,−4,−5,0,−1,0,38,−1,0,25,6,2,1,1,47,20,35,1,−27,1,−5,0,37,−37,−9,−47,−28,5,0,18,8,6,0,−8,−4,− 3,−3,1 },    { 4,10,4,17,−9,4,−2,1,5,14,32,−15,9,−3,2,−1,7,13,19,15,−8,1,−1,0,3,25,30,−18,1,−2,0,−1,11,24,22,−11,−3,37,−13,−58,−5,12,− 63,26,9,−15,11,8 },    { −3,−9,−23,10,−10,3,−3,1,−5,−14,−16,−27,13,−5,2,−1,−1,−13,−30,11,−5,2,−1,0,−5,−8,−22,−16,10,0,1,0,0,−29,−27,6,−27,−10,− 30,9,−3,−10,−7,77,9,−13,45,−8 },    { 2,11,22,2,9,−2,2,0,−6,−7,20,−32,−3,−4,0,−1,13,−5,−28,6,18,−4,3,−1,−26,27,−14,6,−20,0,−2,0,−76,−26,−4,−7,12,51,5,24,7,−17,− 16,−12,−5,4,2,13 },    { 2,−3,8,14,−5,3,−1,1,−2,−11,5,−18,8,−3,2,−1,12,−23,−19,22,2,0,1,0,23,41,−7,35,−10,4,−1,1,5,7,23,5,69,−38,−8,−32,−15,− 31,24,11,2,18,11,−15 },   }  },  { //2   {    { −121,33,4,4,1,2,0,1,−1,−1,1,0,0,0,0,0,24,−5,−1,−1,0,0,0,0,5,−1,0,0,0,0,0,0,3,−1,0,0,2,−1,0,0,2,−1,0,0,1,0,0,0 },    { 0,−2,0,0,0,0,0,0,121,−23,−7,−3,−2,−1,−1,0,17,1,−2,0,0,0,0,0,−27,4,2,0,0,0,0,0,−12,2,1,0,−5,1,0,0,−1,0,0,0,−2,0,0,0 },    { −20,19,−5,2,−1,1,0,0,16,3,−2,0,0,0,0,0,−120,14,8,1,3,1,1,0,−18,−2,3,0,1,0,0,0,17,−3,−1,0,6,−1,−1,0,2,0,0,0,2,0,0,0 },    { 32,108,−43,10,−9,3,−3,1,4,19,−7,1,−1,0,0,0,11,−30,9,−2,1,−1,0,0,0,−8,2,0,0,0,0,0,−7,−1,2,0,−3,−1,1,0,−2,−2,1,0,0,0,0,0 },    { −3,0,−1,0,0,0,0,0,−29,11,−2,1,0,0,0,0,12,7,−1,0,0,0,0,0,−117,12,9,1,3,0,1,0,−32,−3,3,0,12,−2,−1,0,7,0,0,0,1,0,0,0 },    { −4,−12,−3,1,−1,0,0,0,19,105,−31,7,−6,1,−2,0,9,46,−6,0,0,0,0,0,3,−29,9,−3,1,0,0,0,−3,−19,3,0,−4,−6,1,0,0,0,0,0,0,−1,0,0 },    { 7,1,2,0,0,0,0,0,4,3,−2,0,0,0,0,0,22,−8,1,−1,0,0,0,0,−28,−9,4,0,1,0,0,0,117,−10,−8,0,32,1,−4,0,3,1,−1,0,−3,1,0,0 },    { −8,−31,14,−4,3,−1,1,0,9,43,0,1,−1,0,0,0,−13,−105,17,−2,2,0,0,0,−8,−25,−3,0,0,0,0,0,−7,32,−5,1,−1,4,0,0,2,−1,0,0,1,0,−1,0 },    { −15,−43,−100,23,−12,6,−4,2,−6,−17,−48,10,−5,2,−1,1,1,−5,19,−6,3,−1,1,0,2,7,15,−3,1,−1,0,0,4,10,5,−1,0,3,1,0,−2,1,2,0,− 1,1,1,0 },    { −3,1,2,0,0,0,0,0,−6,3,1,0,0,0,0,0,0,3,−2,0,0,0,0,0,−20,8,−2,0,0,0,0,0,30,13,−3,0,−116,6,10,0,−35,−5,4,0,−3,−1,0,0 },    { −1,−6,−3,2,−1,0,0,0,−6,−35,9,0,2,0,0,0,1,−6,11,−2,2,0,,0,−9,−100,17,−1,1,0,0,0,−10,−63,1,2,−17,3,−4,0,−1,9,−1,0,3,4,−1,0 },    { −5,−14,−48,2,−5,1,−2,0,10,24,99,−17,10,−4,3,−1,4,14,32,0,2,0,1,0,−4,0,−39,6,−4,1,−1,0,2,−3,−4,0,2,−2,−2,0,0,0,−1,0,0,−1,− 1,0 },    { −2,0,2,0,0,0,0,0,−2,0,1,0,0,0,0,0,−1,−1,1,−1,0,0,0,0,−1,−4,2,0,0,0,0,0,−3,−2,−1,1,30,4,−4,1,−102,4,8,−1,−69,−2,6,−1 },    { −2,−10,−4,0,0,0,0,0,3,11,−1,−1,0,0,0,0,−6,−40,−15,6,−2,1,0,0,5,57,−6,2,0,0,0,0,1,−95,18,−6,−10,−34,−2,0,−4,17,−2,0,0,2,1,0 },    { −2,−3,−25,−2,−3,0,−1,0,−1,−3,−1,4,−2,2,0,1,−7,−8,−97,17,−9,3,−3,1,−8,−26,−61,−1,−3,−1,−1,−1,2,10,24,−7,5,9,19,−1,0,1,4,0,− 2,0,1,0 },    { 4,−4,28,103,−42,24,−9,7,1,2,4,0,3,−1,0,0,−1,0,−9,−42,17,−9,3,−2,−1,1,−14,6,−4,2,−1,0,−1,−2,−4,4,0,3,1,−1,0,2,0,−2,2,0,0,0 },   },   {    { 87,−41,3−4,1−1,0,−1,−73,28,2,1,1,1,0,0,30,−5,−6,1,−1,0,0,0,−8,−3,3,0,0,0,0,0,3,2,−1,0,−2,−1,0,0,1,1,0,0,−1,0,0,0 },    { −75,4,7,0,2,0,1,0,−41,36,−7,3,−1,1,0,0,72,−29,−2,0,−1,0,−37,6,7,−2,1,0,0,0,12,3,−4,0,−3,−2,1,0,4,0,0,0,−1,0,0,0 },    { 26,−44,22,−6,4,−2,1,−1,77,24,−22,2,−4,0,−1,0,7,−38,10,0,1,0,0,0,−51,27,4,−3,2,−1,1,0,31,−5,−8,3,−14,0,5,−1,6,1,−3,0,−4,− 1,1,0 },    { −39,−68,37,−7,6,−2,2,0,−9,56,−21,1,−2,0,−1,0,−45,4,−3,6,−1,2,0,1,49,−13,3,−3,−1,0,0,0,−19,2,0,0,5,1,1,0,−2,0,−1,0,1,0,0,0 },    { 10,−20,2,0,1,0,0,0,50,−1,8,−5,1,−1,0,0,66,17,−24,4,−3,1,−1,0,13,−49,15,1,0,0,0,0,−53,34,6,−5,30,−7,−11,3,−11,−2,5,1,4,2,−1,− 1 },    { −21,−45,8,−2,3,−1,1,0,−7,−30,26,−8,3,−1,1,−1,−9,69,−33,5,−2,0,−1,0,−44,−31,10,7,−2,2,0,1,49,7,2,−6,−23,−3,−2,2,9,4,0,0,−2,−1,− 1,0 },    { −4,−2,−55,28,−8,5,−3,2,−2,37,43,−19,1,−2,1,−1,−47,−34,−27,5,4,−1,1,0,−39,−2,27,4,−2,1,0,0,−11,32,−8,−7,27,−12,−6,6,−13,0,4,− 3,3,−1,−2,1 },    { 2,19,47,−23,6,−4,2,−1,−23,−22,−44,17,−2,2,−1,0,−33,3,22,−2,−4,1,−1,0,−58,−17,6,−6,7,−1,1,0,−23,40,−2,5,43,−11,−8,−1,−18,− 4,5,2,4,3,0,−1 },    { −19,−62,−9,3,0,0,0,0,−12,−56,27,−7,3,−1,1,0,7,−8,16,−6,4,−2,1,−1,−15,54,−23,2,−1,0,0,0,−42,−25,4,6,34,8,2,−2,−15,−1,0,− 1,3,2,0,1 },    { 1,9,−5,0,−1,0,0,0,0,22,−1,2,0,1,0,0,−13,17,0,−2,0,−1,0,0,−46,−10,−10,4,−1,1,0,0,−80,−27,20,−4,−68,23,−2,−2,20,−3,−2,3,− 14,2,3,−1 },    { 5,17,−9,0,−2,1,0,0,13,54,−2,7,−1,1,0,0,4,51,−3,−6,−1,−1,0,0,−20,6,−34,9,−2,2,−1,0,16,−52,28,1,59,15,−8,−5,−28,− 7,2,2,10,3,0,−1 },    { 7,27,5,−2,10,−3,3,−1,−2,−6,8,−28,3,−4,1,−1,−1,−4,−68,35,−5,5,−2,1,0,35,43,−4,−6,1,−1,0,−14,−38,−12,−10,9,5,7,6,−9,7,−4,−3,4,− 4,0,3 },    { 0,0,19,−4,3,−2,2,−1,−3,−13,10,−4,1,0,0,0,−6,−37,−18,−5,2,−2,1,−1,6,−6,−7,25,−6,4,−1,1,16,10,55,−24,15,46,−52,1,35,− 43,10,12,−23,13,5,−8 },    { −3,0,−27,−80,40,−16,6,−4,4,3,31,61,−22,7,−1,1,−4,−7,−26,−6,−10,6,−4,1,3,8,14,−18,15,−5,2,−1,−2,−4,−1,13,0,2,−4,−3,3,−1,2,1,− 2,0,−2,−1 },    { 1,2,−8,6,−1,1,0,0,2,8,−5,−1,0,0,0,0,1,24,3,5,−1,1,0,0,−3,12,6,−10,1,−1,0,0,−9,−1,−25,10,45,−11,18,2,86,1,−13,−4,−65,−6,7,2 },    { −4,−18,−57,8,−8,1,−3,0,−5,−20,−69,7,−6,2,−2,1,1,4,0,33,−7,5,−2,1,0,−9,53,−22,3,−1,0,0,4,−27,−2,−9,5,36,−13,5,−7,− 17,1,2,4,6,4,−1 },   }  },  { //3   {    { −115,37,9,2,2,1,1,0,10,−29,8,0,1,0,1,0,23,−6,−8,1,−1,0,0,0,3,3,−2,−1,0,0,0,0,4,0,0,−1,1,1,0,0,2,0,0,0,0,0,0,0 },    { 15,51,−18,0,−3,0,−1,0,−95,7,34,−3,5,−1,2,0,23,−47,1,6,0,1,0,1,8,5,−12,0,−1,0,0,0,3,−3,1,−1,2,1,−2,0,1,−1,0,0,1,1,−1,0 },    { 29,−22,16,−6,3,−2,1,−1,−4,−80,12,15,0,3,0,1,45,7,−59,7,−2,1,−1,0,−15,41,−3,−16,2,−3,0,−1,1,0,7,−2,−3,6,1,−2,0,0,1,0,−1,2,0,− 1 },    { −36,−98,25,5,4,1,2,1,−59,11,−17,1,1,1,0,0,6,−13,7,−3,0,0,0,0,14,−4,−14,3,−1,0,0,0,2,8,−3,−5,2,0,0,0,0,3,0,−1,1,0,0,0 },    { −6,18,3,−3,−1,0,0,0,−50,−5,−38,12,0,2,0,1,3,67,−7,−40,3,−6,1,−3,−12,−13,65,−3,−10,0,−1,0,9,−20,−5,22,−2,0,0,−1,2,−3,−2,3,− 1,0,1,0 },    { 4,15,52,−13,5,−3,2,−1,−17,−45,16,24,−2,4,−1,2,−87,−8,−14,7,8,1,2,0,23,−35,−6,−3,1,1,0,0,2,5,−17,0,3,−1,−1,−5,0,1,−4,0,1,0,0,− 2 },    { −20,−7,−43,4,0,1,−1,1,−7,35,0,12,−4,1,−1,0,−51,−2,−57,5,15,0,4,0,7,39,5,−55,1,−7,1,−3,1,−10,41,2,4,−3,−2,3,−1,−2,7,1,1,−1,− 1,0 },    { 4,29,1,26,−5,4,−2,1,−17,−7,−73,6,6,2,1,1,−5,21,−3,5,−1,−3,0,−1,−11,2,−52,−3,27,−2,5,0,0,27,8,−58,2,−5,25,3,0,3,0,−5,0,− 2,7,0 },    { 12,13,10,2,−1,3,−1,1,17,−2,−46,12,7,0,2,0,16,−45,−9,−53,61,1,0,70,16,8,−4,−37,1,−7,0,−12,29,3,21,4,0,5,−1,− 3,4,1,4,2,0,1,0 },    { 5,20,90,−17,4,−3,2,−1,6,66,8,28,−7,3,−1,1,29,5,−19,12,9,−1,1,0,−10,14,−1,−13,7,0,1,0,0,−6,13,−4,0,−4,1,5,0,−1,−1,1,0,− 1,0,0 },    { −3,−4,−34,−12,2,−1,−1,0,5,25,11,43,−10,4,−2,1,23,20,−40,12,21,−3,4,−1,25,−28,−10,5,8,6,0,1,−4,21,−64,−8,−5,19,10,−48,3,− 1,10,−3,0,4,3,−6 },    { −1,−3,2,19,−2,4,−1,2,9,3,−35,22,11,1,2,0,−7,−65,−19,−22,11,4,2,1,−75,−18,3,−1,−10,2,0,1,2,−35,−27,4,1,8,−17,−19,3,0,3,− 6,0,2,−1,−2 },    { 10,−4,−6,12,5,1,1,0,11,−9,−12,−2,−7,0,−1,0,33,−10,−4,18,18,−4,4,−1,28,−72,1,−49,15,2,2,1,56,−23,22,−1,4,−1,−15,26,6,4,− 10,0,0,2,−3,2 },    { 4,6,14,53,−4,4,0,2,0,−1,−20,−13,3,2,−1,1,−3,1,−5,35,−16,−6,−1,−2,46,29,13,21,37,−5,4,−1,−10,−53,−18,8,9,12,−41,−24,− 2,2,13,−16,4,1,−5,1 },    { 2,9,13,37,19,6,2,2,−9,−3,−9,−28,−20,−4,−3,−1,1,18,9,28,24,6,2,2,−20,−5,−25,−33,−36,9,−2,2,−13,42,1,57,−22,−2,−25,− 28,5,6,19,−12,−5,−3,−2,4 },    { 3,−3,12,84,−12,8,−2,3,6,13,50,−1,45,1,7,0,−2,18,−22,−37,−13,14,0,3,1,−12,−3,2,−15,−8,1,−1,19,14,−4,−12,−4,5,17,8,2,−4,− 4,4,−2,2,1,0 },   },   {    { 109,−26,−8,−3,−2,−1,−1,0,−50,28,2,1,0,0,0,0,−18,−8,6,0,1,0,1,0,6,−2,−3,0,0,0,0,0,−3,2,1,−1,0,0,0,0,−2,0,0,0,0,0,0,0 },    { −39,31,−5,2,−1,1,0,0,−95,6,18,0,4,0,1,0,32,−49,5,1,1,0,0,0,27,−1,−14,2,−2,1,−1,0,3,5,−3,−2,4,1,−1,−1,2,0,0,0,2,0,0,0 },    { 29,−3,−2,−2,0,0,0,0,0,−41,9,0,2,0,1,0,86,4,−33,2,−6,1,−2,0,−32,58,1,−7,0,−2,0,−1,−14,−8,20,0,−2,−3,0,4,−1,−1,0,0,−1,1,0,0 },    { 18,96,−23,2,−5,1,−2,0,−10,6,10,−2,1,−1,1,0,−14,26,2,−4,1,−1,0,0,−43,−9,35,−2,4,−1,1,0,14,−40,1,10,2,1,−10,1,2,−4,−1,−1,0,0,− 1,0 },    { −29,−60,16,−2,3,−1,1,0,−52,9,−17,5,−2,1,−1,1,13,56,−2,−9,0,−2,0,−1,−34,−18,41,0,3,0,1,0,19,−36,−10,13,3,6,−14,−1,3,1,−1,− 3,1,1,−1,−1 },    { −23,−5,−15,5,−2,1,−1,1,2,79,−13,−4,−2,−1,−1,0,−9,1,5,−1,1,0,0,0,−4,49,2,−14,1,−3,0,−1,−31,−14,56,−1,13,−37,−4,20,−2,2,− 10,0,2,−4,0,−1 },    { −7,−3,12,−3,3,−1,1,0,−31,−62,8,7,0,2,0,1,−75,9,−45,5,−1,1,−1,0,14,35,0,−23,2,−5,1,−2,1,−8,32,−1,7,−12,−4,10,0,2,−6,−1,2,0,0,− 2 },    { 1,−26,5,0,1,0,1,0,24,−3,43,−6,4,−2,1,−1,−7,−64,9,14,0,3,0,1,−12,−4,5,3,−1,1,0,0,8,−59,−3,26,14,6,−58,6,−5,17,−7,−18,3,3,−1,− 5 },    { 11,14,6,−3,1,−1,1,0,10,−7,−9,3,−2,1,−1,0,22,21,1,−21,2,−4,1,−2,92,1,53,0,−9,1,−2,0,−21,−11,1,40,−5,−4,−24,5,−4,5,−6,− 5,0,0,0,−3 },    { −10,−11,−47,3,−4,1,−1,0,5,28,11,−2,−1,0,0,0,−12,−2,−38,2,0,1,0,0,16,38,11,−16,−1,−3,0,−2,12,−9,−22,7,−8,60,4,−36,−6,− 15,54,7,3,−7,−8,14 },    { −8,−24,−99,11,−10,3,−4,1,−5,−36,19,−26,4,−5,1,−2,0,25,41,5,−3,1,0,0,10,−5,−7,12,2,1,0,0,−1,1,9,−3,−3,−14,−3,12,2,4,−13,−2,− 1,3,2,−4 },    { −5,1,−1,0,1,0,0,0,−10,−14,−6,8,0,1,0,0,−17,−2,7,−5,3,−1,0,0,−16,13,3,31,−1,6,0,2,−93,−15,−46,−3,23,−19,0,− 47,8,4,8,3,2,3,0,0 },    { 1,12,−20,21,−4,5,−2,2,−5,−2,−75,9,−1,2,−1,1,−1,−2,−16,−4,0,−1,0,0,−7,7,−31,0,3,0,0,0,4,11,−12,4,−12,14,−50,−1,−8,32,−4,− 54,2,0,30,−15 },    { 2,−9,−118,8,−3,3,−1,1,3,−25,−26,−6,0,−2,0,−1,−6,−61,14,−51,2,−6,0,−2,−19,0,40,−7,−17,0,−3,0,13,−4,11,9,17,0,24,5,1,− 12,4,28,0,0,−15,8 },    { 4,9,39,18,0,2,0,1,−6,−16,−22,−37,5,−5,1,−2,−5,15,63,9,−16,0,−3,0,18,42,−18,27,15,1,3,1,12,−34,9,−24,4,28,−2,4,−11,− 4,30,2,5,−13,−4,18 },    { −7,−2,15,−6,1,−1,1,−1,−11,−3,22,−14,0,−2,1,−1,−18,−7,30,−9,−4,0,−1,0,−35,23,23,10,−17,1,−3,0,−19,53,6,43,−65,12,−12,11,−8,− 16,10,−21,−2,−12,6,2 },   }  } },

When the RST is performed by applying an m×48 transform matrix (m≤16) to an 8×8 region, 64 pieces of data are inputted and m coefficients may be generated. Table 14 shows an example of a transform kernel matrix when m is 16, and 48 pieces of data is inputted and 16 coefficients are generated. That is, assuming that 48 pieces of data form a 48×1 vector, a 16×1 vector may be generated by sequentially multiplying a 16×48 matrix and a 48×1 vector. At this time, 48 pieces of data forming an 8×8 region may be properly arranged to form a 48×1 vector, and the input data can be arranged in the following order.

TABLE 15  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

When the RST is performed, as shown in Table 14, when a matrix operation is performed by applying a maximum 16×48 transform kernel matrix, 16 modified transform coefficients are generate, the 16 modified transform coefficients can be arranged in the top-left 4×4 region according to the scanning order, and the top-right 4×4 region and the bottom-left 4×4 region can be filled with zeros. Table 16 shows an example of the arrangement order of 16 modified transform coefficients generated through the matrix operation.

TABLE 16 1  3  6 10 2  5  9 13 4  8 12 15 7 11 14 16

As shown in Table 16, the modified transform coefficient generated when the maximum 16×48 transform kernel matrix is applied can be filled in the top-left 4×4 region according to the scanning order. In this case, the number of each position in the top-left 4×4 region indicates the scanning order. Typically, the coefficient generated from an inner product operation of the topmost row of the 16×48 transform kernel matrix and the 48×1 input column vector is the first in the scanning order. In this case, the direction of going down to the bottom row and the scanning order may match. For example, a coefficient generated by the inner product of a 48×1 input column vector and an nth row from the top in a 16×48 transform kernel matrix is placed nth in a scanning order.

In the case of the maximum 16×48 transform kernel matrix, the 4×4 region in the top-right of Table 16 is the region to which the secondary transformation is not applied, so the original input data (primary transform coefficient) is preserved as it is, and the 4×4 region in the top-right 4×4 region and the bottom-left 4×4 region will be filled with zeros.

In addition, according to another embodiment, a scanning order other than the scanning order shown in Table 16 may also be applied. For example, a row-first direction or a column first direction may be applied as a scanning order.

In addition, even if the 16×64 transform kernel matrix shown in Table 8 is applied, 16 transform coefficients are equally generated, so the 16 transform coefficients can be arranged in the scanning order shown in Table 16 and in the case of applying the 16×64 transform kernel matrix since the matrix operation is performed using all 64 input data instead of 48, zeros are filled in all 4×4 regions except for the top-right 4×4 region. Also in this case, the scanning order in the diagonal direction as shown in Table 16 may be applied, and other scanning order such as the row first direction or the column first direction be applied.

On the other hand, when inverse RST or LFNST is performed as an inverse transformation process performed by the decoding apparatus, the input coefficient data to which the inverse RST is applied includes a 1D vector according to the arrangement order of Table 16, and the modified coefficient vector obtained by multiplying the 1D vector and the corresponding inverse RST matrix from the left can be arranged in a 2D block according to the arrangement order in Table 15.

Then, the inverse transformer 322 of the decoding apparatus may apply the transform kernel matrix to transform coefficients arranged in one dimension according to the scanning order in Table 16. That is, 48 modified transform coefficients can be derived through the matrix operation between the one dimensional transform coefficients arranged according to the scanning order in Table 16 and the transform kernel matrix based on the transform kernel matrix in Table 14. That is, the one-dimensional transform coefficients can be derived into the 48 modified transform coefficients through the matrix operation with a matrix in which the transform kernel matrix in Table 14 is transposed.

The 48 modified transform coefficients derived in this way can be arranged in two dimensions as shown in Table 15 for the inverse primary transform.

In summary, in the transformation process, when RST or LFNST is applied to the 8×8 region, the transform operation is performed between 48 transform coefficients among the transform coefficients of the 8×8 region in the top-left, the top-right and the bottom-left regions of the 8×8 region excluding the bottom-right region of the 8×8 region and the 16×48 transform matrix kernel. For the matrix operation, 48 transform coefficients are inputted in a one-dimensional array in the order shown in Table 15. When such a matrix operation is performed, 16 modified transform coefficients are derived, and the modified transform coefficients may be arranged in the form shown in Table 16 in the top-left region of the 8×8 region.

Conversely, in the inverse conversion process, when inverse RST or LFNST is applied to the 8×8 region, 16 transform coefficients corresponding to the top-left of the 8×8 region among the transform coefficients of the 8×8 region are input in a one-dimensional array form according to the scanning order shown in Table 16, so that the transform operation is performed between the 48×16 transform kernel matrix and the 16 transform coefficients. That is, the matrix operation in this case can be expressed as (48×16 matrix)*(16×1 transform coefficient vector)=(48×1 modified transform coefficient vector). Here, since the n×1 vector can be interpreted in the same meaning as the n×1 matrix, it may be expressed as an n×1 column vector. Also, * means matrix multiplication operation. When such a matrix operation is performed, the 48 modified transform coefficients can be derived, and the 48 modified transform coefficients may be arranged in the top-left, the top-right, and the bottom-left region excluding the bottom-right region of the 8×8 region as shown in Table 15.

Meanwhile, according to an embodiment, as shown in Table 15, data arrangement in an 8×8 region for the secondary transformation is in row-first order. When there are 67 intra prediction modes as shown in FIG. 5, all directional modes (mode 2 to mode 66) are symmetrically configured about mode 34. That is, mode (2+n) is symmetric to mode (66−n) (0≤n≤31) about mode 34 in terms of prediction direction. Therefore, if a data arrangement order for configuring a 48×1 input vector for mode (2+n), that is, modes 2 to 33, corresponds to the row-first direction as shown in Table 15, a 48×1 input vector for mode (66−n) may be configured in an order shown in Table 17.

TABLE 17 1  9 17 25 33 37 41 45 2 10 18 26 34 38 42 46 3 11 19 27 35 39 43 47 4 12 20 28 36 40 44 48 5 13 21 29 6 14 22 30 7 15 23 31 8 16 24 32

As shown in Table 11, the data is arranged in the column-first direction in the 8×8 region for a secondary transform. Table 17 shows that, for intra prediction mode (66−n), that is, for modes 35 to 66, a 48×1 input vector may be configured for according to the column-first direction.

In summary, the same transform kernel matrix shown in Table 14 may be applied while symmetrically arranging input data for mode (2+n) according to the row-first direction and input data for mode (66−n) (0≤n≤31) according to the column-first direction. A transform kernel matrix to be applied in each mode is shown in Table 5 to Table 7.

Here, either the arrangement order shown in Table 15 or the arrangement order shown in Table 17 may be applied for the planar mode of intra prediction mode 0, the DC mode of intra prediction mode 1, and the intra prediction mode 34. For example, for the planar mode of intra prediction mode 0, the DC mode of intra prediction mode 1, and the intra prediction mode 34, input data may be arranged according to the row-first direction as shown in Table 15 and the arrangement order shown in Table 16 can be applied to the derived transform coefficients. Alternatively, for the planar mode of intra prediction mode 0, the DC mode of intra prediction mode 1, and the intra prediction mode 34, input data may be arranged according to the column-first direction as shown in Table 17 and the arrangement order shown in Table 16 can be applied to the derived transform coefficients.

As described above, when the 16×48 transform kernel matrix of Table 14 is applied to the secondary transformation, the top-right 4×4 region and the bottom-left 4×4 region of the 8×8 region are filled with zeros as shown in Table 16. When an m×48 transform kernel matrix is applied to the secondary transform (m≤16), not only the top-right 4×4 region and the bottom-left 4×4 region, but also from the (m+1)th to 16th in the scanning order shown in Table 16 can be filled with zeros.

Therefore, if there is any non-zero transform coefficient from the (m+1)th to 16th position in the scanning order or in the top-right 4×4 region or the bottom-left 4×4 region, it can be considered that the m×48 secondary transform is (m≤16) is not applied. In this case, the index for the secondary transformation may not be signaled. The decoding apparatus first parses the transform coefficient and checks whether the corresponding condition (that is, if a non-zero transform coefficient exists in the region where the transform coefficient should be 0) is satisfied and if it is satisfied the decoding apparatus may infer the index for the secondary transformation to zero without parsing the index. For example, in the case of m=16, it may be determined whether to apply the secondary transformation and whether to parse the index for the secondary transformation by checking whether there is a non-zero coefficient in the top-right 4×4 region or the bottom-left 4×4 region.

Meanwhile, Table 18 shows another example of transform kernel matrices that can be applied to a 4×4 region.

TABLE 18 const int g_aiNsst4x4[4][2][16][16] = { {//0 { {108, −44, −15, 1, −44, 19, 7, −1, −11, 6, 2, −1, 0, −1, −1, 0}, {−40, −97, 56, 12, −11, 29, −12, −3, 18, 18, −15, −3, −1, −3, 2, 1}, {25, −31, −1, 7, 100, −16, −29, 1, −54, 21, 14, −4, −7, 2, 4, 0}, {−32, −39, −92, 51, −6, −16, 36, −8, 3, 22, 18, −15, 4, 1, −5, 2}, {8, −9, 33, −8, −16, −102, 36, 23, −4, 38, −27, −5, 5, 16, −8, −6}, {−25, 5, 16, −3, −38, 14, 11, −3, −97, 7, 26, 1, 55, −10, −19, 3}, {8, 9, 16, 1, 37, 36, 94, −38, −7, 3, −47, 11, −6, −13, −17, 10}, {2, 34, −5, 1, −7, 24, −25, −3, 8, 99, −28, −29, 6, −43, 21, 22}, {−16, −27, −39, −109, 6, 10, 16, 24, 3, 19, 10, 24, −4, −7, −2, −3}, {−9, −10, −34, 4, −9, −5, −29, 5, −33, −26, −96, 33, 14, 4, 39, −14}, {−13, 1, 4, −9, −30, −17, −3, −64, −35, 11, 17, 19, −86, 6, 36, 14}, {8, −7, −5, −15, 7, −30, −28, −87, 31, 4, 4, 33, 61, −5, −17, 22}, {−2, 13, −6, −4, −2, 28, −13, −14, −3, 37, −15, −3, −2, 107, −36, −24}, {4, 9, 11, 31, 4, 9, 16, 19, 12, 33, 32, 94, 12, 0, 34, −45}, {2, −2, 8, −16, 8, 5, 28, −17, 6, −7, 18, −45, 40, 36, 97, −8}, {0, −2, 0, −10, −1, −7, −3, −35, −1, −7, −2, −32, −6, −33, −16, −112}, }, { {119, −30, −22, −3, −23, −2, 3, 2, −16, 3, 6, 0, −3, 2, 1, 0}, {−27, −101, 31, 17, −47, 2, 22, 3, 19, 30, −7, −9, 5, 3, −5, −1}, {0, 58, 22, −15, −102, 2, 38, 2, 10, −13, −5, 4, 14, −1, −9, 0}, {23, 4, 66, −11, 22, 89, −2, −26, 13, −8, −38, −1, −9, −20, −2, 8}, {−19, −5, −89, 2, −26, 76, −11, −17, 20, 13, 18, −4, 1, −15, 3, 5}, {−10, −1, −1, 6, 23, 25, 87, −7, −74, 4, 39, −5, 0, −1, −20, −1}, {−17, −28, 12, −8, −32, 14, −53, −6, −68, −67, 17, 29, 2, 6, 25, 4}, {1, −24, −23, 1, 17, −7, 52, 9, 50, −92, −15, 27, −15, −10, −6, 3}, {−6, −17, −2, −111, 7, −17, 8, −42, 9, 18, 16, 25, −4, 2, −1, 11}, {9, 5, 35, 0, 6, 21, −9, 34, 44, −3, 102, 11, −7, 13, 11, −20}, {4, −5, −5, −10, 15, 19, −2, 6, 6, −12, −13, 6, 95, 69, −29, −24}, {−6, −4, −9, −39, 1, 22, 0, 102, −19, 19, −32, 30, −16, −14, −8, −23}, {4, −4, 7, 8, 4, −13, −18, 5, 0, 0, 21, 22, 58, −88, −54, 28}, {−4, −7, 0, −24, −7, 0, −25, 3, −3, −30, 8, −76, −34, 4, −80, −26}, {0, 6, 0, 30, −6, 1, −13, −23, 1, 20, −2, 80, −44, 37, −68, 1}, {0, 0, −1, 5, −1, −7, 1, −34, −2, 3, −6, 19, 5, −38, 11, −115}, } }, {//1 { {−111, 39, 4, 3, 44, 11, −12, −1, 7, −16, −5, 2, 3, −1, 4, 2}, {−47, −27, 15, −1, −92, 43, 20, −2, 20, 39, −16, −5, 10, −5, −13, 2}, {−35, −23, 4, 4, −17, −72, 32, 6, −59, 18, 50, −6, 0, 40, 0, −13}, {13, 93, −27, −4, −48, 13, −34, 4, −52, 11, 1, 10, 3, 16, −3, 1}, {−11, −27, 1, 2, −47, −4, −36, 10, −2, −85, 14, 29, −20, −2, 57, 4}, {0, −35, 32, −2, 26, 60, −3, −17, −82, 1, −30, 0, −37, 21, 3, 12}, {−17, −46, −92, 14, 7, −10, −39, 29, −17, 27, −28, 17, 1, −15, −13, 17}, {4, −10, −23, 4, 16, 58, −17, 26, 30, 21, 67, 2, −13, 59, 13, −40}, {5, −20, 32, −5, 8, −3, −46, −7, −4, 2, −15, 24, 100, 44, 0, 5}, {−4, −1, 38, −18, −7, −42, −63, −6, 33, 34, −23, 15, −65, 33, −20, 2}, {−2, −10, 35, −19, 5, 8, −44, 14, −25, 25, 58, 17, 7, −84, −16, −18}, {5, 13, 18, 34, 11, −4, 18, 18, 5, 58, −3, 42, −2, −10, 85, 38}, {−5, −7, −34, −83, 2, −1, −4, −73, 4, 20, 15, −12, 4, −3, 44, 12}, {0, 4, −2, −60, 5, 9, 42, 34, 5, −14, 9, 80, −5, 13, −38, 37}, {−1, 2, 7, −57, 3, −7, 9, 68, −9, 6, −49, −20, 6, −4, 36, −64}, {−1, 0, −12, 23, 1, −4, 17, −53, −3, 4, −21, 72, −4, −8, −3, −83}, }, { {88, −55, 6, −3, −66, 27, 9, −2, 11, 11, −13, 1, −2, 7, 1, 2}, {−58, −20, 27, −2, −27, 75, −29, 0, 47, −42, −11, 11, −9, −3, 19, −4}, {−51, 23, −22, 5, −63, 3, 37, −5, 1, 64, −35, −4, 29, −31, −11, 13}, {−27, −76, 49, −2, 40, 14, 9, −17, −56, 36, −25, 6, 14, 3, −6, 8}, {19, −4, −36, 22, 52, 7, 36, −23, 28, −17, −64, 15, −5, −44, 48, 9}, {29, 50, 13, −10, 1, 34, −59, 1, −51, 4, −16, 30, 52, −33, 24, −5}, {−12, −21, −74, 43, −13, 39, 18, −5, −58, −35, 27, −5, 19, 26, 6, −5}, {19, 38, −10, −5, 28, 66, 0, −5, −4, 19, −30, −26, −40, 28, −60, 37}, {−6, 27, 18, −5, −37, −18, 12, −25, −44, −10, −38, 37, −66, 45, 40, −7}, {−13, −28, −45, −39, 0, −5, −39, 69, −23, 16, −12, −18, −50, −31, 24, 13}, {−1, 8, 24, −51, −15, −9, 44, 10, −28, −70, −12, −39, 24, −18, −4, 51}, {−8, −22, −17, 33, −18, −45, −57, −27, 0, −31, −30, 29, −2, −13, −53, 49}, {1, 12, 32, 51, −8, 8, −2, −31, −22, 4, 46, −39, −49, −67, 14, 17}, {4, 5, 24, 60, −5, −14, −23, 38, 9, 8, −34, −59, 24, 47, 42, 28}, {−1, −5, −20, −34, 4, 4, −15, −46, 18, 31, 42, 10, 10, 27, 49, 78}, {−3, −7, −22, −34, −5, −11, −36, −69, −1, −3, −25, −73, 5, 4, 4, −49}, } }, {//2 { {−112, 47, −2, 2, −34, 13, 2, 0, 15, −7, 1, 0, 8, −3, −1, 0}, {29, −7, 1, −1, −108, 40, 2, 0, −45, 13, 4, −1, 8, −5, 1, 0}, {−36, −87, 69, −10, −17, −33, 26, −2, 7, 14, −11, 2, 6, 8, −7, 0}, {28, −5, 2, −2, −29, 13, −2, 0, 103, −36, −4, 1, 48, −16, −4, 1}, {−12, −24, 15, −3, 26, 80, −61, 9, 15, 54, −36, 2, 0, −4, 6, −2}, {18, 53, 69, −74, 14, 24, 28, −30, −6, −7, −11, 12, −5, −7, −6, 8}, {5, −1, 2, 0, −26, 6, 0, 1, 45, −9, −1, 0, −113, 28, 8, −1}, {−13, −32, 18, −2, 15, 34, −27, 7, −25, −80, 47, −1, −16, −50, 28, 2}, {−4, −13, −10, 19, 18, 46, 60, −48, 16, 33, 60, −48, 1, 0, 5, −2}, {15, 33, 63, 89, 8, 15, 25, 40, −4, −8, −15, −8, −2, −6, −9, −7}, {−8, −24, −27, 15, 12, 41, 26, −29, −17, −50, −39, 27, 0, 35, −67, 26}, {−2, −6, −24, 13, −1, −8, 37, −22, 3, 18, −51, 22, −23, −95, 17, 17}, {−3, −7, −16, −21, 10, 24, 46, 75, 8, 20, 38, 72, 1, 2, 1, 7}, {2, 6, 10, −3, −5, −16, −31, 12, 7, 24, 41, −16, −16, −41, −89, 49}, {4, 8, 21, 40, −4, −11, −28, −57, 5, 14, 31, 70, 7, 18, 32, 52}, {0, 1, 4, 11, −2, −4, −13, −34, 3, 7, 20, 47, −6, −19, −42, −101}, }, { {−99, 39, −1, 2, 65, −20, −5, 0, −15, −2, 5, −1, 0, 3, −1, 0}, {58, 42, −33, 3, 33, −63, 23, −1, −55, 32, 3, −5, 21, −2, −8, 3}, {−15, 71, −44, 5, −58, −29, 25, 3, 62, −7, −4, −4, −19, 4, 0, 1}, {46, 5, 4, −6, 71, −12, −15, 5, 52, −38, 13, −2, −63, 23, 3, −3}, {−14, −54, −29, 29, 25, −9, 61, −29, 27, 44, −48, 5, −27, −21, 12, 7}, {−3, 3, 69, −42, −11, −50, −26, 26, 24, 63, −19, −5, −18, −22, 12, 0}, {17, 16, −2, 1, 38, 18, −12, 0, 62, 1, −14, 5, 89, −42, 8, −2}, {15, 54, −8, 6, 6, 60, −26, −8, −30, 17, −38, 22, −43, −45, 42, −7}, {−6, −17, −55, −28, 9, 30, −8, 58, 4, 34, 41, −52, −16, −36, −20, 16}, {−2, −1, −9, −79, 7, 11, 48, 44, −13, −34, −55, 6, 12, 23, 20, −11}, {7, 29, 14, −6, 12, 53, 10, −11, 14, 59, −15, −3, 5, 71, −54, 13}, {−5, −24, −53, 15, −3, −15, −61, 26, 6, 30, −16, 23, 13, 56, 44, −35}, {4, 8, 21, 52, −1, −1, −5, 29, −7, −17, −44, −84, 8, 20, 31, 39}, {−2, −11, −25, −4, −4, −21, −53, 2, −5, −26, −64, 19, −8, −19, −73, 39}, {−3, −5, −23, −57, −2, −4, −24, −75, 1, 3, 9, −25, 6, 15, 41, 61}, {1, 1, 7, 18, 1, 2, 16, 47, 2, 5, 24, 67, 3, 9, 25, 88}, } }, {//3 { {−114, 37, 3, 2, −22, −23, 14, 0, 21, 0, −17, −5, 2, 5, 2, −4, −1}, {−19, −41, 19, −2, 85, −60, −11, 7, 17, 31, −34, 2, −11, 19, 2, −8}, {36, −25, 18, −2, −42, −53, 35, 5, 46, −60, −25, 19, 8, 21, −33, −1}, {−27, −80, 44, −3, −58, 1, −29, 19, −41, 18, −12, −7, 12, −17, 7, −6}, {−11, −21, 37, −10, 44, −4, 47, −12, −37, −41, 58, 18, 10, −46, −16, 31}, {15, 47, 10, −6, −16, −44, 42, 10, −80, 25, −40, 21, −23, −2, 3, −14}, {13, 25, 79, −39, −13, 10, 31, −4, 49, 45, 12, −8, 3, −1, 43, 7}, {16, 11, −26, 13, −13, −74, −20, −1, 5, −6, 29, −47, 26, −49, 54, 2}, {−8, −34, −26, 7, −26, −19, 29, −37, 1, 22, 46, −9, −81, 37, 14, 20}, {−6, −30, −42, −12, −3, 5, 57, −52, −2, 37, −12, 6, 74, 10, 6, −15}, {5, 9, −6, 42, −15, −18, −9, 26, 15, 58, 14, 43, 23, −10, −37, 75}, {−5, −23, −23, 36, 3, 22, 36, 40, 27, −4, −16, 56, −25, −46, 45, −24}, {1, 3, 23, 73, 8, 5, 34, 46, −12, 2, 35, −38, 26, 52, 2, −31}, {−3, −2, −21, −52, 1, −10, −17, 44, −19, −20, 30, 45, 27, 61, 49, 21}, {−2, −7, −33, −56, −4, −6, 21, 63, 15, 31, 32, −22, −10, −26, −52, −38}, {−5, −12, −18, −12, 8, 22, 38, 36, −5, −15, −51, −63, −5, 0, 15, 73}, }, { {−102, 22, 7, 2, 66, −25, −6, −1, −15, 14, 1, −1, 2, −2, 1, 0}, {12, 93, −27, −6, −27, −64, 36, 6, 13, 5, −23, 0, −2, 6, 5, −3}, {−59, −24, 17, 1, −62, −2, −3, 2, 83, −12, −17, −2, −24, 14, 7, −2}, {−33, 23, −36, 11, −21, 50, 35, −16, −23, −78, 16, 19, 22, 15, −30, −5}, {0, −38, −81, 30, 27, 5, 51, −32, 24, 36, −16, 12, −24, −8, 9, 1}, {28, 38, 8, −9, 62, 32, −13, 2, 51, −32, 15, 5, −66, 28, 0, −1}, {11, −35, 21, −17, 30, −18, 31, 18, −11, −36, −80, 12, 16, 49, 13, −32}, {−13, 23, 22, −36, −12, 64, 39, 25, −19, 23, −36, 9, −30, −58, 33, −7}, {−9, −20, −55, −83, 3, −2, 1, 62, 8, 2, 27, −28, 7, 15, −11, 5}, {−6, 24, −38, 23, −8, 40, −49, 0, −7, 9, −25, −44, 23, 39, 70, −3}, {12, 17, 17, 0, 32, 27, 21, 2, 67, 11, −6, −10, 89, −22, −12, 16}, {2, −9, 8, 45, 7, −8, 27, 35, −9, −31, −17, −87, −23, −22, −19, 44}, {−1, −9, 28, −24, −1, −10, 49, −30, −8, −7, 40, 1, 4, 33, 65, 67}, {5, −12, −24, −17, 13, −34, −32, −16, 14, −67, −7, 9, 7, −74, 49, 1}, {2, −6, 11, 45, 3, −10, 33, 55, 8, −5, 59, 4, 7, −4, 44, −66}, {−1, 1, −14, 36, −1, 2, −20, 69, 0, 0, −15, 72, 3, 4, 5, 65}, } } };

As described above, each of four transform sets mapped to an intra prediction mode may include two transform kernel matrices, and transform indices of 0, 1, 2, and 3 may be used for indicating the transform kernel matrices. Table 8 and Table 14 illustrate transform kernel matrices applied to an 8×8 region, and Table 9 and Table 18 illustrate transform kernel matrices applicable to a 4×4 region.

According to another embodiment of the present disclosure, as shown in Table 7, one transform kernel matrix may be used for one transform set. In this embodiment, one transform kernel matrix may be applied for all intra prediction modes, and the following transform matrices may be used, for example.

Table 19 illustrates a transform kernel matrix applied to an 8×8 region, and Table 20 and Table 18 illustrate transform kernel matrix applicable to a 4×4 region. The details explained with reference to Table 8, Table 9, Table 14, and Table 18 may also be applied to the transform kernel matrices illustrated in Table 19 and Table 20.

TABLE 19 const int g_aiNsst8x8[4][1][16][64] = { {//0 { {117, −31, −15, −3, −3, −1,−1,−1, −32, 14, 3, 1, 1, 0, 0, 0, −12, 2, 2, 0, 1, 0, 0, 0, −3, 1, 0, 0, 0, 0, 0, 0, −3, 1, 1, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0}, {−33, −80, 44, −1, 9, 0, 3, 0, −68, 28, 2, 1, 1, 0, 0, 0, 36, 5, −9, −1, −2, 0, −1, 0, −1, 2, −1, 0, 0, 0, 0, 0, 8, 1, −2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 0, −1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {3, −78, 17, 6, 4, 2, 2, 1, 89, 1, −28, 0, −4, 0, −2, 0, −25, 25, 1, −3, 0, −1, 0, 0, −6, 0, 3, 0, 0, 0, 0, 0, −6, 4, 0, 0, 0, 0, 0, 0, −2, 0, 1, 0, 0, 0, 0, 0, −2, 1, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0}, {−11, −33, −33, 18, −2, 5, −1, 2, −26, −100, 33, 5, 6, 2, 2, 1, −20, 35, 1, −6, 0, −1, 0, −1, 14, 5, −4, −2, −1, 0, 0, 0, −2, 6, 0, −1, 0, 0, 0, 0, 3, 2, −1, 0, 0, 0, 0, 0, −1, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0}, {30, 23, 91, −34, 3, −8, 2, −3, 12, −57, 1, 14, 0, 3, 0, 1, 25, −1, −29, 6, 0, 1, 0, 1, −11, 8, 2, −2, 0, 0, 0, 0, 1, 0, −3, 1, 0, 0, 0, 0, −3, 2, 0, 0, 0, 0, 0, 0, 0, 0, −2, 0, 0, 0, 0, 0, −1, 1, 0, 0, 0, 0, 0, 0}, {−11, 5, 48, −13, 2, −3, 1, −2, −23, 14, 11, 0, 0, −1, 0, 0, −104, −11, 15, 5, 5, 2, 2, 1, 38, −6, −11, 1, −1, 0, −1, 0, −5, 1, −3, 0, 0, 0, 0, 0, 9, −1, −2, 0, 0, 0, 0, 0, −2, 0, −1, 0, 0, 0, 0, 0, 3, 0, −1, 0, 0, 0, 0, 0}, {−6, −18, −19, −13, 6, −1, 2, 0, −17, −36, −79, 20, 1, 6, 0, 2, −11, −77, 17, 13, 3, 3, 1, 1, −7, 19, 12, −2, −1, −1, 0, −1, 4, 2, 4, −1, −1, 0, 0, 0, −1, 4, 2, −1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 2, 1, −1, 0, 0, 0, 0}, {−2, 27, 2, −1, −1, −1, 0, 0, −30, 3, −80, 19, 2, 3, 0, 1, −10, 83, −2, −19, 2, −4, 0, −2, −1, −14, 18, −1, −1, 0, 0, 0, 1, −2, 0, 2, 0, 0, 0, 0, 1, −3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, −1, 1, 0, 0, 0, 0, 0}, {10, 10, 32, 113, −22, 9, −7, 3, −1, −1, −12, 13, 5, −l, 0, 0, 1, −22, −17, −19, 7, 0, 1, 0, 10, 3, 0, −5, −2, 0, 0, 0, −2, 1, 0, −4, 1, −1, 0, 0, 1, 1, 1, −1, 0, 0, 0, 0, 0, 0, 0, −2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {−8, 2, 7, 12, −2, 1, −1, 0, −11, −2, 18, 0, 0, −1, 0, 0, −36, 0, 10, −1, 3, 0, 1, 0, −114, −11, 22, 2, 5, 1, 2, 0, 20, −3, −8, 0, −1, 0, 0, 0, −9, 0, 1, 0, 0, 0, 0, 0, 6, 0, −2, 0, 0, 0, 0, 0, −3, 0, 0, 0, 0, 0, 0, 0}, {−3, −4, −12, 1, −4, 2, −1, 1, −5, −5, −11, −51, 12, −4, 3, −1, −14, −9, −81, 40, 5, 3, 0, 1, 6, −45, 42, 23, −5, 1, −1, 0, −4, 12, 8, −8, −3, 0, 0, 0, 2, −5, 3, 1, 0, 0, 0, 0, −2, 3, 0, −1, 0, 0, 0, 0, 1, −1, 1, 1, 0, 0, 0, 0}, {−8, −2, −22, −12, −2, −1, −1, 0, 1, 21, 16, 60, −8, 2, −2, 1, −21, 3, −74, −4, 15, 1, 2, 0, −5, 58, 11, −37, −3, −1, 0, −1, −3, −5, 13, 7, −2, −1, 0, 0, 1, 2, −1, −2, 1, 0, 0, 0, −1, −2, 2, 1, 0, 0, 0, 0, 0, 1, 0, −1, 0, 0, 0, 0}, {0, 7, 8, 4, −2, 2, 0, 0, −7, −1, −13, −83, 7, −3, 3, −1, −7, 13, 2, −9, −8, −1, −1, 0, −6, 92, 7, −3, −2, −5, 0, −2, −2, −2, 9, 3, 1, 0, 0, 0, 0, 1, −1, 4, 0, 0, 0, 0, 0, −3, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0}, {5, 2, −5, −1, 0, 0, 0, 0, 7, 1, 0, −2, −2, 1, 0, 0, −4, 2, −8, −3, 4, 0, 0, 0, 22, 8, 1, −1, 1, −1, 0, 0, 109, 27, −45, −4, −2, −1, −2 −1, −28, −3, 7, 1, 1, 0, 0, 0, 7, 2, −2, 0, 0, 0, 0, 0, −3, 0, 1, 0, 0, 0, 0, 0}, {5, 8, −3, 26, 113, −29, 9, −4, 0, −1, 3, 0, −21, 8, −2, 1, −5, −1, −10, −3, −36, 6, −1, 1, 1, −2, 6, −1, 5, −3, 0, 0, 1, 0, 2, 0, −3, 1, 0, 0, 0, 0, 0, 1, 0, −1, 0, 0, 0, 0, 0, −1, −1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {−1, 5, −4, 13, −1, 1, 0, 0, −4, 3, −17, 10, 1, 1, −1, 1, −4, 17, −16, 71, −11, 2, −1, 0, −19, 19, −83, 25, 21, −2, 3, −1, −6, 15, −15, −28, 4, 2, 1, 0, 0, −2, 0, −2, −2, 0, 0, 0, 0, 1, 0, −3, 0, 0, 0, 0, −1, 1, 0, −1, 0, 0, 0, 0}, } }, {//1 { {94, −53, 2, −4, 1, −1, 0, −1, −63, 19, 11, 0, 2, 0, 1, 0, 7, 14, −8, −1, −1, 0, 0, 0, −3, −4, −1, 2, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, −1, 0, −1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0}, {−65, −8, 16, 0, 4, 0, 1, 0, −64, 65, −6, 0, −1, 0, 0, 0, 50, −9, −21, 4, −3, 1, −1, 0, 0, −15, 7, 3, 0, 1, 0, 0, 8, 0, 1, −2, −1, 0, 0, 0, 0, −3, 1, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0}, {32, −18, 11, −2, 1, −1, 1, 0, 57, 38, −39, 1, −6, 0, −2, 0, 37, −33, 2, 12, −2, 3, −1, 1, −25, 3, 31, −8, 2, −1, 1, 0, −1, 6, −8, −5, 2, −1, 0, 0, −7, 0, 2, 2, 1, 0, 0, 0, 0, 1, −1, −1, 0, 0, 0, 0, −3, 0, 1, 0, 0, 0, 0, 0}, {−36, −69, 34, −2, 5, −1, 2, 0, −14, −9, 1, 0, 1, 1, 0, 0, −40, −13, 43, 1, 2, 0, 1, 0, −14, 59, 4, −24, 3, −3, 1, −1, 3, 5, −31, 2, 5, 0, 1, 0, 0, 3, 0, 7, −1, 0, 0, 0, 3, 1, −4, 1, 0, 0, 0, 0, 0, 1, 0, 2, −1, 0, 0, 0}, {19, 73, −17, −1, −4, 0, −1, 0, −60, −18, −29, 15, −1, 4, −1, 1, 3, −37, 45, 7, −1, 1, 0, 1, −5, 27, 12, −24, 2, −3, 1, −1, 4, 1, −19, 1, 5, −1, 1, 0, −1, −1, 0, 5, −1, 0, 0, 0, 3, 0, −1, 1, 0, 0, 0, 0, 1, 0, 1, 1, −1, 0, 0, 0}, {−14, −25, −19, 6, −2, 2, −1, 1, −5, −66, 37, 9, 1, 2, 0, 1, 73, −5, 19, −17, −1, −2, 0, −1, −33, −18, 14, −9, 6, −1, 2, 0, −8, 32, 3, −10, 4, −2, 1, −1, −4, 4, −16, 2, 3, −1, 0, 0, 0, 4, 1, 4, −2, −1, 0, 0, −1, 0, −2, −2, 0, 1, 0, 0}, {6, 1, 12, −7, −1, −2, 0, −1, 14, 6, −14, 7, 0, 2, 0, 1, 45, 18, 27, −20, −5, −4, −1, −2, −19, 14, −70, −15, 11, 0, 2, 0, 0, −29, 1, 58, −2, 2, −1, 1, 7, −4, 32, −16, −22, 2, −3, 0, 0, −6, −3, −13, 11, 3, 0, 1, −2, 2, 2, 2, 0, −4, 0, 0}, {14, 22, 6, −3, 0, 0, 0, 0, 25, 36, 26, −11, 0, −2, 0, −1, 32, 42, 5, −18, 0, −2, 0, −1, 21, 28, −7, −31, 2, −5, 0, −2, −9, 5, −58, −23, 16, −1, 3, 0, −8, −8, −31, 35, 18, −1, 2, 0, 2, 0, 1, 21, −9, −3, −1, 0, 1, −4, −1, 4, −3, 2, 0, 0}, {−2, −28, 6, 3, 0, 0, 0, 0, 1, −31, −24, 7, −2, 2, −1, 1, 31, −4, 20, 20, −5, 3, −1, 1, 94, −15, 11, −15, −9, −1, −3, 0, 0, −47, 0, −12, 6, 0, 1, 0, −7, −1, 15, 2, 5, −1, 1, 0, −3, 2, 4, −2, −1, −1, 0, 0, 0, 2, 3, −2, 0, 0, 0, 0}, {−9, −23, −94, 22, −10, 6, −4, 2, 7, 43, 25, 28, −8, 5, −2, 2, −20, −17, 28, −23, −7, 0, −8, 0, 14, −8, −4, −15, 10, 1, 1, 0, 3, −7, 1, 5, 6, −2, 1, 0, −1, 0, 8, 0, −1, −1, 0, 0, −2, 2, −1, −4, 1, −1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0}, {0, 2, −7, 20, −8, 2, −2, 1, 0, −6, 13, −31, 12, −3, 4, −2, −5, 9, −24, 38−12, 3, −3, 1, 4, −20, 30, −41, 4, 2, 1, 0, −19, 26, −40, 37, 16, −8, 3, −2, 19, −20, 34, 5, −37, 8, −4, 2, −5, 4, −4, −28, 20, 4, −1, 1, 2, −2, 0, 13, −2, −6, 2, 0}, {−2, −4, 20, −11, −4, −2, 0, −1, 3, 16, −41, 19, 4, 4, 0, 1, −19, 30, 39, 4, −21, 1, −4, 1, −1, −55, −3, −39, 16, 4, 2, 1, −27, 35, 25, 6, 19, −9, 4, −2, 1, 26, −36, −2, −5, −1, 0, −1, −4, −8, 0, 15, −2, 2, −2, 1, 4, 2, −1, −7, −1, 0, 0, 0}, {9, 16, 24, 12, −3, 1, 0, 0, 14, 27, 38, 15, −4, 2, 1, 0, 14, 28, 43, 14, −9, 0, −1, −1, 14, 27, 40, 2, −17, −2, −3, −1, 18, 21, 31, −17, −27, −3, −4, −1, 9, 3, 7, −46, −20, 3, −1, 1, −1, −3, −10, −31, 8, 7, 2, 1, 0, 0, −5, −10, 7, 1, 1, 0}, {−7, −19, −53, −4, 1, −3, −1, −1, 4, −4, −63, 16, 8, 0, 1, 0, 19, 54, −8, 44, 4, −1, 1, 0, −18, 35, 7, 20, −21, −5, −3, −1, −5, 12, −10, −6, −21, 1, −2, 0, 0, −5, −10, −1, −6, 5, 0, 1, 1, −2, 1, 3, −1, 4, 0, 1, 0, −1, 1, 1, 0, 2, 0, 0}, {0, −1, 2, −4, 0, 0, 1, 1, −1, −2, −3, 3, 8, −4, −1, −1, 1, −12, −4, −22, 6, −4, 3, 2, 34, 8, 10, 32, 56, −11, 7, −4, −12, 15, −17, 26, −50, −37, 0, −9, −19, −1, −30, 0, −42, 28, 8, 3, 5, 2, 9, 11, 5, 19, −8, 1, 3, −2, 1, −5, −1, −1−5, 2}, {−2, 2, −3, 76, 5, −7, 3, −3, 4, −6, 21, 61, 21, −4, 3, 0, −3, −3, −36, 5, −50, 6, −5, 0, −2, 18, 14, −15, 13, 18, −4, 3, 0, −12, 1, −2, 12, −13, −1, 0, 3, −2, 9, −1, −2, 1, 5, −1, 3, 0, 0, −5, 3, −1, −2, −1, −2, −2, 0, 2, −1, −1, 0, 0}, } }, {//2 { {121, −34, −4, −5, −1, −2, 0, −1, −5, 1, 0, 0, 0, 0, 0, 0, −20, 5, 1, 1, 0, 0, 0, 0, −4, 1, 0, 0, 0, 0, 0, 0, −3, 1, 0, 0, 0, 0, 0, 0, −2, 1, 0, 0, 0, 0, 0, 0, −2, 1, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0}, {−5, 0, 1, 0, 0, 0, 0, 0, −122, 23, 6, 3, 2, 1, 1, 0, −2, 2, 0, 0, 0, 0, 0, 0, 26, −4, −2, 0, −1, 0, 0, 0, 9, −2, −1, 0, 0, 0, 0, 0, 5, −1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {17, −15, 3, −2, 1, −1, 0, 0, −3, 2, 0, 0, 0, 0, 0, 0, 123, −13, −8, −2, −2, −1, −1, 0, 3, −1, −1, 0, 0, 0, 0, 0, −18, 3, 1, 0, 0, 0, 0, 0, −5, 1, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0}, {−31, −108, 42, −8, 8, −2, 3, −1, 0, −27, 11, −2, 2, 0, 1, 0, −6, 28, −7, 1, −1, 0, −1, 0, 7, 8, −3, 0, −1, 0, 0, 0, 7, 1, −2, 0, 0, 0, 0, 0, 0, 1, 2, −1, 0, 0, 0, 0, 0, 1, 2, −1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {8, 6, −3, 1, 0, 0, 0, 0, 26, −7, −1, −1, 0, 0, 0, 0, 0, −3, 0, 0, 0, 0, 0, 0, 122, −10, −9, −2, −3, −1, −1, 0, 21, −2, −1, 0, −1, 0, 0, 0, −9, 1, 1, 0, 0, 0, 0, 0, −4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {−5, −14, 3, −1, 1, 0, 0, 0, 20, 105, −26, 5, −5, 1, −2, 0, 3, 52, −12, 2, −2, 0, −1, 0, 2, −25, 5, −1, 1, 0, 0, 0, −2, −20, 4, −1, 1, 0, 0, 0, −2, −4, 1, −1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, −2, 0, 0, 0, 0, 0, 0}, {6, −1, 0, −1, 0, 0, 0, 0, 6, 6, −2, 0, −1, 0, 0, 0, 15, −11, 2, −1, 0, 0, 0, 0, −21, 2, 2, 0, 0, 0, 0, 0, 123, −3, −9, 0, −3, 0, −1, 0, 11, −2, −1, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0}, {9, 34, −9, 2, −2, 1, −1, 0, −8, −48, 8, −1, 2, 0, 1, 0, 16, 101, −15, 2, −3, 0, −1, 0, −3, 13, −3, 1, 0, 0, 0, 0, 9, −41, 5, −2, 1, 0, 0, 0, 1, 0, −1, −1, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, −2, 0, 0, 0, 0, 0, 0}, {−12, −33−83, 14, −5, 3, −4, 2, −8, −22, −79, 13, −4, 3, −3, 1, −1, −1, −10, 3, 1, 0, 0, 0, 2, 6, 21, −2, 2, −1, 1, 0, 3, 5, 16, −3, 1, 0, 0, 0, −4, 2, 7, −1, 0, 0, 0, 0, −1, 2, 2, 0, 0, 0, 0, 0, −1, 1, 1, 0, 0, 0, 0, 0}, {−2, 2, 5, −1, 0, 0, 0, 0, −6, 1, 2, 0, 0, 0, 0, 0, −3, 0, 0, 0, 0, 0, 0, 0, −10, 2, −2, 0, 0, 0, 0, 0, 11, 2, −1, 0, 0, 0, 0, 0, −125, 4, 9, 0, 3, 0, 1, 0, −16, 0, 2, 0, 0, 0, 0, 0, 5, 0, −1, 0, 0, 0, 0, 0}, {−1, −8, −1, 0, −1, 0, 0, 0, −3, −24, 6, 0, 0, 0, 0, 0, −3, −23, 6, 0, 1, 0, 0, 0, −9, −101, 14, 0, 3, 0, 0, 0, −1, −66, 7, −2, 1, 0, 0, 0, −2, 11, −2, −1, 0, 0, 0, 0, 0, 13, −1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0}, {9, 26, 78, −18, 5, −3, 3, −2, −7, −18, −74, 15, −4, 2, −3, 1, −4, −10, −40, 6, 0, 1, −2, 1, 3, 2, 34, −3, 1, 0, 1, 0, 0, 0, 3, −1, −1, 0, 0, 0, 2, 1, 4, −1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, −1, 0, 0, 0, 0, 0}, {−2, 0, 1, 0, 0, 0, 0, 0, −2, 1, 1, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0, 0, 0, 0, −2, −1, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 11, −1, −1, 0, 0, 0, 0, 0, −102, 3, 7, 0, 2, 0, 1, 0, −76, 2, 6, 0, 2, 0, 1, 0}, {−2, −8, 0, 2, 0, 0, 0, 0, 2, 16, 0, −3, 1, 0, 0, 0, −3, −37, −1, 2, 0, 0, 0, 0, 5, 71, 0, 2, 0, 0, 0, 0, −5, −95, 3, −8, 1, −1, 0, 0, −1, 7, −5, −1, 0, 0, 0, 0, 0, 19, −1, 2, 0, 0, 0, 0, 0, −5, 1, 1, 0, 0, 0, 0}, {0, 0, 8, −5, 2, 0, 0, 0, −1, −4, −24, 7, −2, 0, −1, 0, 7, 16, 90, −14, 5, −2, 3, −1, 4, 6, 40, −4, 4, −1, 1, 0, −6, −6, −70, 9, −4, 1, −2, 0, −3, −4, 17, 1, 0, 1, 0, 0, −1, 1, 1, 1, 1, 0, 0, 0, 1, −1, 0, 0, 0, 0, 0, 0}, {−2, 3, −18, −68, 46, −19, 5, −4, −1, 2, −11, −52, 34, −14, 4, −2, 0, 0, 4, 26, −14, 5, −1, 2, 1, −1, 6, 52, −25, 11, −2, 2, 0, −1, 1, 15, −5, 3, 0, 0, 0, 0, 0, −3, 2, −1, 0, 0, 0, 0, 0, −3, 1, 0, 0, 0, 0, 0, 0, −1, 0, 0, 0, 0}, } }, {//3 { {−113, 35, 11, 3, 2, 1, 1, 0, 23, −32, 5, 0, 1, 0, 0, 0, 23, −4, −9, 1, −1, 0, 0, 0, 2, 3, −2, −1, 0, 0, 0, 0, 4, 0, −1, −1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, −45, 16, −1, 3, 0, 1, 0, 93, −10, −33, 3, −5, 1, −2, 0, −26, 54, −5, −7, 0, −1, 0, −1, −13, −3, 16, −2, 1, 0, 0, 0, −3, 0, 0, 3, 0, 0, 0, 0, −2, −1, 2, 0, 1, 0, 0, 0, −1, 1, 0, 0, 0, 0, 0, 0, −1, 0, 1, 0, 0, 0, 0, 0}, {−31, 17, −10, 5, −2, 2, −1, 1, 6, 76, −14, −11, −1, −3, 0, −1, −49, −6, 58, −7, 3, −1, 2, −1, 16, −47, 2, 17, −1, 3, 0, 1, 0, 1, −12, 1, 2, 0, 0, 0, 3, −5, −1, −1, −1, 1, 0, 0, 0, 1, −1, 0, 0, 0, 0, 0, 1, −2, 0, 0, 0, 0, 0, 0}, {−36, −100, 34, 4, 6, 1, 2, 0, −43, 5, −21, 6, 1, 1, 0, 1, 6, −15, 1, −3, 0, 0, 0, 0, 21, −6, −19, 3, −2, 0, −1, 0, 0, 15, −6, −7, 1, −1, 0, 0, 3, 1, 1, −2, −1, 0, 0, 0, 0, 3, 0, −1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {11, −10, −4, 2, 0, 0, 0, 0, 58, −2, 35, −11, 1, −3, 0, −1, −8, −63, 11, 36, −4, 6, −1, 3, 5, 13, −66, 10, 5, 0, 1, 0, −11, 22, −1, −22, 6, −3, 1, −1, 3, −1, 3, −4, −2, 0, −1, 0, −2, 3, 2, −3, −1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {13, 19, 41, −12, 5, −3, 2, −1, −15, −66, 14, 20, 0, 4, 0, 1, −63, −2, −5, 3, 5, 1, 1, 0, 17, −51, −4, 10, −1, 3, 0, 1, 4, 8, −37, −1, 3, 0, 0, 0, 1, 4, 2, −11, −2, 0, 0, 0, 1, 2, −5, 1, −1, 0, 0, 0, 0, 1, 1, −3, 0, 0, 0, 0}, {−17, −2, −15, 3, 2, 0, 1, 0, −8, 16, 6, 7, −2, 3, −1, 1, −74, −13, −49, 9, 13, 1, 3, 0, 19, 24, 0, −59, 3, −3, 0, −2, 6, −5, 43, 5, −21, 1, −4, 0, 4, −2, −7, 15, 4, −2, 0, −1, −1, −1, 4, −2, 1, 2, 1, 0, 2, −1, −1, 2, 0, −1, 0, 0}, {−4, 24, −18, 13, −1, 3, −1, 1, −22, 7, −56, 15, 5, 2, 0, 1, −14, 32, −24, 1, 5, 1, 0, 0, −28, 13, −50, 3, 14, −1, 3, −1, −9, 25, −11, −54, 18, −5, 4, −3, 6, −7, 29, −24, −9, 2, −1, 0, 2, 0, 5, −2, −4, −1, −1, 0, 0, −1, 6, −3, −2, 2, −1, 0}, {7, −4, −70, 17, −6, 5, −2, 2, 11, −46, −49, −13, 8, −2, 2, −1, 2, −32, 10, −40, 1, −2, 0, −1, 50, −4, 9, −2, −15, 1, −4, 0, −3, 22, −4, 9, −4, 0, 1, 0, 0, 4, 2, 0, 0, −1, 0, 0, −1, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, −1, 0, 0, 0, 0}, {20, 37, 73, −6, 1, −1, 1, 0, 19, 28, −40, 27, 1, 3, 0, 1, 23, −30, −15, −28, 7, −2, 2, −1, 42, 14, 2, −7, −11, 0, −3, 0, −16, 22, 11, 5, −2, 0, 0, 0, 0, −6, 6, 5, 1, 0, 0, 0, −3, 0, −1, 1, 0, 1, 0, 0, 1, −2, 1, 1, 0, 0, 0, 0}, {−9, −11, −20, −11, 5, 0, 0, 0, 8, 25, 24, 24, −5, 0, 0, 0, −15, −17, −40, −14, 8, 1, 0, 0, 13, 34, 33, 28, −11, −4, −2, −2, −24, −18, −45, 10, 44, 5, 9, 1, 5, 2, 5, −50, −14, 5, 1, 2, −2, −3, 4, 12, −4, −6, −3, −1, 2, 3, 0, −10, 2, 4, 0, 0}, {4, −6, −23, −1, 8, −1, 0, 0, 16, 24, 6, 25, −7, 5, −1, 1, 43, −8, −38, 9, 35, −2, 6, −1, −5, −69, −5, −47, 4, 14, 0, 3, 4, 4, −35, −3, −26, 0, −2, 0, −4, 13, 1, −11, 0, −4, −1, −2, 5, 2, 1, 1, −2, 2, 1, 0, −2, 2, 0, −3, 0, −1, 1, 0}, {−1, 5, −2, 12, 2, −1, 0, −1, −4, 4, −13, 2, 8, 1, −2, 0, −2, 9, −8, 22, 2, 0, −1, −2, 2, 8, −11, 9, 14, 0, 1, 0, −9, 18, −17, 43, 11, −5, 2, −3, −13, 2, −36, −19, 73, −6, 9, −3, 6, −15, 10, −58, 9, 24, −3, 6, −1, −1, −4, −4, −16, 8, −2, 1}, {−2, 1, −13, −18, 2, −5, 0, −1, −5, 7, 42, −7, −14, 0, −3, 0, 12, 60, 2, 20, −2, −3, 0, −1, 67, 3, −1, 1, 2, 0, 0, 0, −18, 56, 6, 0, −2, −4, 1, −1, −5, −11, 35, 2, 6, −1, 0, 0, −2, −3, −2, 11, 0, 3, 0, 1, −1, −2, 3, 0, 2, −1, 0, 0}, {4, 2, 0, 11, −2, 0, 0, −1, 3, −3, −11, 5, 12, 0, −3, 0, 7, 0, 1, 26, −1, −1, 0, −5, 34, −3, 19, 4, 77, −7, 8, −2, 0, −11, 2, −22, 9, 63, −4, 13, −14, 5, −27, 2, −32, 9, 19, −1, 0, −6, 0, −13, 0, −13, 2, 1, 0, 0, −4, −1, −4, 1, −2, 1}, {−2, 4, −6, −78, 11, −11, 6, −4, −2, 6, −34, −50, −28, 7, −6, 2, 1, −15, −34, 16, −48, −1, −3, −1, −1, −22, 1, 4, 5, −24, 4, −5, −4, −3, 2, 1, 7, −3, −5, 2, 0, 2, −3, 0, 1, 0, −2, 0, 2, 0, 2, −1, 2, −1, −2, 0, 0, 0, 0, 1, 1, 0, −1, 0}, } } };

TABLE 20 const int g_aiNsst4x4[4][1][16][16] = { {//0 { {106, −48, −11, 0, −47, 16, 8, 0, −9, 8, 0, 0, −1, 0, 0, 0}, {−49, −83, 58, 4, −29, 38, −3, −6, 28, 13, −20, 0, 0, −3, 1, 1}, {17, −55, 12, 9, 94, −17, −30, 1, −46, 25, 9, −4, −6, 4, 3, −1}, {−26, −34, −39, 28, −24, −75, 56, 8, −3, 47, 5, −18, 9, 7, −13, 0}, {23, 23, 87, −42, −9, −64, 10, 19, −6, 10, −31, 9, 2, 11, −4, −4}, {21, −10, −18, 7, 31, −28, −13, 8, 98, −7, −26, −3, −52, 11, 19, −3}, {−13, −23, −6, −6, −37, −37, −71, 44, 0, −36, 58, 3, 7, 29, 5, −20}, {0, 26, −10, −2, −20, 7, −63, 19, 7, 88, −19, −24, 13, −39, 22, 4}, {−14, −22, −40, −109, 1 1, 11, 18, 16, 6, 19, 10, 28, −4, −7, −3, −2}, {12, 17, 37, −3, 14, 22, 25, 9, 34, 32, 89, −41, −16, −1, −34, 4}, {0, 1, −4, 14, 15, 32, 29, 106, −10, −13, −30, −27, 5, −1, −3, −29}, {15, −7, −4, 1, 25, −6, −9, −2, 47, −11, −8, 6, 105, −10, −43, 4}, {2, −14, 10, 1, 2, −26, 15, 12, 2, −37, 24, −2, 1, −105, 40, 20}, {5, 9, 11, 29, 7, 10, 22, 8, 13, 32, 29, 85, 18, 4, 47, −53}, {−2, 1, −3, 23, −7, −4, −19, 20, −4, 7, −7, 63, −41, −38, −88, 10}, {1, 2, 3, 12, 2, 7, 7, 37, 3, 8, 9, 33, 9, 33, 26, 108}, } }, {//1 { {101, −45, −2, −3, −60, 4, 14, 0, 1, 20, −4, −2, −2, −3, −5, 1}, {55, 26, −17, 1, 64, −71, −1, 3, −43, −6, 31, −3, −4, 19, −4, −6}, {45, −3, 4, 0, 49, 44, −37, −1, 43, −68, −18, 13, −18, −17, 32, 1}, {−21, −101, 36, 2, 46, −6, 36, −11, −11, −6, 3, −8, −16, 18, 5, −2}, {17, 16, −8, 1, 55, 18, 37, −15, 18, 56, −57, −18, 8, −41, −37, 23}, {−9, −9, −20, 3, −5, −59, 27, 13, 96, −7, 31, −14, 1, −28, 0, −13}, {−14, −22, −57, 16, −13, −35, 14, 1, −33, −21, −49, 20, 16, −40, 59, 31}, {−7, −18, −93, 12, 11, 45, 8, 33, −6, 7, 23, −20, −44, 21, −17, −13}, {1, −37, −19, 2, 23, 14, −49, 24, 3, 23, 23, 16, 96, −12, −12, −14}, {−10, −26, 1, −11, 1, −37, −80, 13, 11, 45, −24, 30, −59, −10, −16, 13}, {5, 6, −16, 14, 6, −7, 3, −12, 42, 24, −38, 17, 21, 100, 30, 14}, {5, 13, 18, 7, 15, 20, 8, 12, 0, 66, 33, 3, −16, −21, 90, −27}, {−4, −5, −33, −97, 3, 7, −1, −68, 4, 7, 25, 10, 2, −1, 12, 13}, {0, 5, 10, −74, 4, −4, 29, 82, −4, −8, −38, 21, 4, 9, 2, −33}, {−3, −6, −6, −12, −6, −15, −35, −19, −6, −2, −43, −91, 7, 4, 17, −61}, {1, 0, 13, −22, 0, 2, −15, 44, 2, 1, 18, −67, 7, 8, 19, 91}, } }, {//2 { {−112, 48, −3, 4, −28, 12, 1, 0, 20, −10, 1, 0, 6, −4, 0, 0}, {22, −23, 13, −3, −113, 42, 2, 1, −11, 9, −2, 0, 20, −8, −1, 0}, {−43, −85, 69, −14, 6, −32, 18, −2, 17, 17, −17, 4, 3, 6, −5, 1}, {24, −6, 1, −1, 2, 19, −14, 2, 115, −40, −6, 2, 16, −11, 1, 0}, {−12, −13, 22, −12, 36, 87, −67, 12, −12, 28, −21, 6, −13, −14, 13, −2}, {21, 58, 66, −72, 7, 14, 35, −29, −7, −17, −10, 16, −3, −5, −6, 7}, {5, 15, −9, 1, 20, −7, 8, −5, 1, 52, −29, 3, 106, −24, −12, 2}, {−9, −25, 14, −2, 15, 7, −14, 5, −39, −82, 52, −6, 52, −35, 10, 0}, {−6, −20, −14, 24, 23, 59, 69, −58, 9, 18, 38, −31, −7, −9, −7, 10}, {−14, −31, −65, −89, −6, −10, −22, −40, 5, 11, 20, 14, 2, 4, 8, 7}, {−5, −13, −24, −16, −2, −5, 22, −22, −12, −25, −65, 43, −25, −79, 22, 13}, {−5, −15, −19, 11, 7, 27, 4, −15, −17, −44, −43, 36, 16, 66, −65, 20}, {3, 8, 18, 20, −10, −24, −53, −84, −6, −13, −31, −61, 2, 6, 6, 3}, {0, 2, 3, −8, −4, 12, −21, 17, 3, 12, 17, −24, −21, −52, 58, 59}, {4, 10, 23, 38, −5, −12, −29, −41, 9, 23, 51, 82, 2, 5, 11, 39}, {0, −1, −3, −6, −2, 4, 11, 25, −2, −6, −15, −26, 9, 26, 57, 103}, } }, {//3 { {−113, 38, 4, 3, −14, −28, 12, −1, 25, −15, −7, 2, 3, 4, −4, −1}, {20, 37, −18, 3, −92, 43, 23, −6, −3, −49, 24, 4, 14, −11, −11, 5}, {−34, 31, −20, 4, 29, 65, −25, −9, −54, 37, 44, −14, 0, −32, 23, 9}, {33, 93, −47, 4, 55, −13, 39, −15, 17, −8, −3, 13, −17, 19, −6, −1}, {−7, −28, 30, −4, 45, −9, 45, −9, −28, −58, 43, 28, 13, −36, −36, 31}, {7, 28, 18, −7, −25, −47, 30, 17, −89, 22, −41, 15, −1, −22, 9, −17}, {−22, −39, −74, 30, 8, 17, −14, −4, −41, −30, −38, 15, −1, 26, −42, −28}, {−9, 8, 54, −28, 12, 76, 25, 18, 3, 4, −37, 38, −32, 32, −19, −23}, {11, 36, 19, −7, 28, 8, −51, 42, 6, −40, −30, −14, 73, −25, −12, −23}, {5, 21, 20, 5, −1, −19, −54, 29, −23, −47, 22, −26, −83, 15, −13, 5}, {4, 19, 5, 20, −14, −6, −32, 15, −1, 46, −5, 37, 14, 15, −67, 76}, {1, −7, −21, 29, −1, 7, −8, 29, 33, −4, −31, 52, −41, −83, 27, 11}, {−1, 2, −15, −89, −4, −5, −37, −66, −1, −12, −31, 10, −12, −25, −10, 19}, {−6, −11, −42, −65, −3, −13, −2, 71, −2, 3, 43, 45, 10, 25, 22, −2}, {−1, −6, −20, −30, −2, 2, 32, 35, 18, 32, 4, −60, −20, −45, −70, −22}, {5, 10, 16, 12, −9, −20, −30, −31, 10, 23, 48, 52, −1, −14, −35, −80}, } } };

The following embodiments may be proposed in order to reduce computational amount in a worst case. In this document, a matrix including M rows and N columns is expressed as an M×N matrix, and the M×N matrix refers to a transform matrix applied in a forward transform, that is, when the encoding apparatus performs a transform (RST). Accordingly, in the inverse transform (inverse RST) performed by the decoding apparatus, an N×M matrix obtained by transposing the M×N matrix may be used. In addition, the following describes a case where an m×64 transform kernel matrix (m≤16) is applied as a transformation matrix for an 8×8 region, but the same may be applied to a case where input vector is 48×1 and the m×48 transform kernel matrix is (m≤16). That is, 16×64 (or m×64) may be replaced with 16×48 (or m×48).

1) In a case of a block (e.g., a transform unit) having a width of W and a height of H where W≥8 and H≥8, a transform kernel matrix applicable to an 8×8 region is applied to a top-left 8×8 region of the block. In a case where W=8 and H=8, only an 8×64 portion of a 16×64 matrix may be applied. That is, eight transform coefficients may be generated. Alternatively, only 8×48 parts of the 16×48 matrix can be applied. That is, 8 transform coefficients can be generated.

2) In a case of a block (e.g., a transform unit) having a width of W and a height of H where one of W and H is less than 8, that is, one of W and H is 4, a transform kernel matrix applicable to a 4×4 region is applied to a top-left region of the block. In a case where W=4 and H=4, only an 8×16 portion of a 16×16 matrix may be applied, in which case eight transform coefficients are generated.

If (W, H)=(4, 8) or (8, 4), a secondary transform is applied only to the top-left 4×4 region. If W or H is greater than 8, that is, if one of W and H is equal to or greater than 16 and the other is 4, the secondary transform is applied only to two top-left 4×4 blocks. That is, only atop-left 4×8 or 8×4 region may be divided into two 4×4 blocks, and a designated transform kernel matrix may be applied thereto.

3) In a case of a block (e.g., a transform unit) having a width of W and a height of H where both W and H are 4, a secondary transform may not be applied.

4) In a case of a block (e.g., a transform unit) having a width of W and a height of H, the number of coefficients generated by applying a secondary transform may be maintained to be ¼ or less of the region of the transform unit (i.e., the total number of pixels included in the transform unit=W×H). For example, when both W and H are 4, a top 4×16 matrix of a 16×16 matrix may be applied so that four transform coefficients are generated.

Assuming that a secondary transform is applied only to a top-left 8×8 region of the entire transform unit (TU), eight or less coefficients need to be generated for a 4×8 transform unit or a 8×4 transform unit, and thus a top 8×16 matrix of a 16×16 matrix may be applied to a top left 4×4 region. Up to a 16×64 matrix (or 16×48 matrix) may be applied to an 8×8 transform unit (up to 16 coefficients can be generated). In a 4×N or N×4 (N≥16) transform unit, a 16×16 matrix may be applied to a top-left 4×4 block, or a top 8×16 matrix of the 16×16 matrix may be applied to two top-left 4×4 blocks. Similarly, in a 4×8 transform unit or 8×4 transform unit, eight transform coefficients may be generated by applying a top 4×16 matrix of the 16×16 matrix to two top-left 4×4 blocks.

5) The maximum size of a secondary transform applied to a 4×4 region may be limited to 8×16. In this case, the amount of a memory required to store transform kernel matrices applied to the 4×4 region can be reduced by half compared to that in a 16×16 matrix.

For example, in all transform kernel matrices shown in Table 9 or Table 18, the maximum size may be limited to 8×16 by extracting only a top 8×16 matrix of each 16×16 matrix, and an actual image coding system may be implemented to store only 8×16 matrices of the transform kernel matrices.

If the maximum applicable transform size is 8×16 and the maximum number of multiplications required to generate one coefficient is limited to 8, an up to 8×16 matrix may be applied to a 4×4 block, and an up to 8×16 matrix may be applied to each of up to two top-left two 4×4 blocks included in a 4×N block or an N×4 block (N≥8, N=2n, n≥3). For example, an 8×16 matrix may be applied to one top-left 4×4 block in a 4×N block or an N×4 block (N≥8, N=2n, n≥3).

According to an embodiment, when coding an index specifying a secondary transform to be applied to a luma component, specifically, when one transform set includes two transform kernel matrices, it is necessary to specify whether to apply the secondary transform and which transform kernel matrix to apply in the secondary transform. For example, when no secondary transform is applied, a transform index may be coded as 0, and when the secondary transform is applied, transform indexes for two transform sets may be coded as 1 and 2, respectively.

In this case, when coding the transform index, truncated unary coding may be used. For example, binary codes of 0, 10, and 11 may be respectively allocated to transform indexes 0, 1, and 2, thereby coding the transform indexes.

In addition, when coding the transform index by truncated unary coding, different CABAC context may be assigned to each bin. When coding the transform indexes 0, 10, and 11 in the above example, two CABAC contexts may be used.

When coding a transform index specifying a secondary transform to be applied to a chroma component, specifically, when one transform set includes two transform kernel matrices, it is necessary to specify whether to apply the secondary transform and which transform kernel matrix to apply in the secondary transform similarly to when coding the transform index of the secondary transform for the luman component. For example, when no secondary transform is applied, a transform index may be coded as 0, and when the secondary transform is applied, transform indexes for two transform sets may be coded as 1 and 2, respectively.

In this case, when coding the transform index, truncated unary coding may be used. For example, binary codes of 0, 10, and 11 may be respectively allocated to transform indexes 0, 1, and 2, thereby coding the transform indexes.

In addition, when coding the transform index by truncated unary coding, different CABAC context may be assigned to each bin. When coding the transform indexes 0, 10, and 11 in the above example, two CABAC contexts may be used.

According to an embodiment, a different CABAC context set may be allocated according to a chroma intra prediction mode. For example, when chroma intra prediction modes are divided into non-directional modes, such as a planar mode or a DC mode, and other directional modes (i.e., divided into two groups), a corresponding CABAC context set (including two contexts) may be allocated for each group when coding 0, 10, and 11 in the above example.

When the chroma intra prediction modes are divided into a plurality of groups and a corresponding CABAC context set is allocated, it is necessary to find out a chroma intra prediction mode value before coding the transform index of a secondary transform. However, in a chroma direct mode (DM), since a luma intra prediction mode value is used as it is, it is also necessary to find out an intra prediction mode value for a luma component. Therefore, when coding information on a chroma component, data dependency on luma component information may occur. Thus, in the chroma DM, when coding the transform index of the secondary transform without having information on the intra prediction mode, the data dependency can be removed by mapping to a specific group. For example, if the chroma intra prediction mode is the chroma DM, the transform index may be coded using a corresponding CABAC context set assuming the planner mode or the DC mode, or a corresponding CABAC context set may be applied assuming that other directional modes.

Hereinafter, a transform applied to a technique of intra sub partition (ISP) coding is described. ISP coding means that one coding block is partitioned into two or four subblocks and is then coded. In ISP, for one subblock, the intra prediction is performed to with reference to the value of a reconstructed pixel of a left neighboring subblock or a top neighboring subblock. As used herein, “coding” may be used as a concept including both coding performed by an encoding apparatus and decoding performed by a decoding apparatus.

FIG. 9 and FIG. 10 illustrate examples in which one coding block is partitioned into subblocks. Specifically, FIG. 9 illustrates an example of partitioning a coding block (width (W)×height (H)) that is a 4×8 block or 8×4 block, and FIG. 10 illustrates an example of partitioning a coding block that is not a 4×8 block, a 8×4 block, or a 4×4 block.

When ISP is applied, subblocks may be sequentially coded according to a partition type, for example, horizontally, vertically, left to right, or top to bottom, in which one subblock may be subjected to inverse transform, intra prediction, and reconstruction, after which a next subblock may be coded. For the leftmost or topmost subblock, a reconstructed pixel of a coding block already coded is used for reference as in a conventional intra prediction method. Further, when each side of a subsequent inner subblock is not adjacent to a previous subblock, the subblock is coded using derived reference pixels adjacent to the side and is coded with reference to a reconstructed pixel of an adjacent coding block already coded as in the conventional intra prediction method.

In an ISP coding mode, all subblocks may be coded with the same intra prediction mode, and a flag indicating whether to use ISP coding and a flag indicating a direction (horizontal or vertical) in which partition is performed may be signaled. As shown in FIG. 9 and FIG. 10, the number of subblocks may be adjusted to 2 or 4 depending on a block shape, and when the size (width×height) of one subblock is less than 16, partition into the corresponding number of subblocks may not be allowed or a restriction of not applying ISP coding may be set.

When the ISP coding mode is applied, a non-separable secondary transform, such as an RST, may be applied as follows. Further, as described above, when ISP coding is applied, transform or inverse transform may be performed in subblocks.

First, according to an example, when ISP is applied, a non-separable secondary transform, such as an RST, may not be applied. That is, when the ISP is applied, an encoding apparatus may directly quantize a transform coefficient that has been subjected to a forward primary transform, and a decoding apparatus may directly perform an inverse primary transform on a result of inverse quantization as an input.

According to another example, a non-separable secondary transform, such as an RST, may be applied to each subblock partitioned by ISP.

Since the RST can be applied only when both the width and the height of a subblock are 4 or greater, the RST may not be applied when the length of one side of a partitioned subblock is less than 4. When the size of all subblocks includes a 4×4 region or greater, the RST can be applied to each subblock. When a subblock includes an 8×8 region or greater, a transform kernel applicable to an 8×8 region, for example, a 16×64 or 16×48 transform kernel matrix, may be applied, otherwise, a transform kernel applicable to a 4×4 region, for example, a 16×16 transform kernel matrix, may be applied to one or two 4×4 blocks disposed at the top-left of the subblock. Further, as described above, the encoding apparatus and the decoding apparatus may apply the non-separable secondary transform in consideration of the amount of computation in the worst case.

In summary, according to an example, regarding an individual subblock as a transform unit to which the RST is applicable, that is, a transform target block, the same RST application method as described above may be applied to each subblock.

According to an example, the same RST transform matrix may be applied to all subblocks, or a different RST transform matrix may be applied to each subblock. As described above, since a transform set for a secondary transform may be determined by an intra prediction mode, the same transform set may be applied to all subblocks into which one coding block is partitioned by ISP, but a different transform kernel matrix to be used in each transform set may be set for each subblock. For example, when one transform set includes two transforms, that is, two transform kernel matrices, a transform index indicating a transform kernel matrix may have a value ranging from 0 to 2. A transform index of 0 may indicate a case where a non-separable secondary transform, such as an RST, is not applied, a transform index of 1 may indicate a case where a first transform kernel matrix is applied, and a transform index of 2 may indicate a case where a second transform kernel matrix is applied. When the same transform kernel matrix is applied to all subblocks, one transform index may be signaled for an entire block before partition into the subblocks, for example, a coding block. That is, although an individual transform process may be performed on each subblock, only one transform kernel matrix applied to the secondary transform may be used, and a transform index indicating the transform kernel matrix may be signaled for the coding block before partition.

The following drawings are provided to describe specific examples of the present disclosure. Since the specific designations of devices or the designations of specific signals/messages/fields illustrated in the drawings are provided for illustration, technical features of the present disclosure are not limited to specific designations used in the following drawings.

FIG. 11 is a flowchart illustrating an operation of a video decoding apparatus according to an embodiment of the present disclosure.

Each operation illustrated in FIG. 11 may be performed by the decoding apparatus 300 illustrated in FIG. 3. Specifically, S1110 may be performed by the entropy decoder 310 illustrated in FIG. 3, S1120 may be performed by the dequantizer 321 illustrated in FIGS. 3, S1130 and S1140 may be performed by the inverse transformer 322 illustrated in FIG. 3, and S1150 may be performed by the adder 340 illustrated in FIG. 3. Operations according to S1110 to S1150 are based on some of the foregoing details explained with reference to FIG. 4 to FIG. 10. Therefore, a description of specific details overlapping with those explained above with reference to FIG. 3 to FIG. 10 will be omitted or will be made briefly.

The decoding apparatus 300 according to an embodiment may derive quantized transform coefficients for a target block from a bitstream (S1110). Specifically, the decoding apparatus 300 may decode information on the quantized transform coefficients for the target block from the bitstream and may derive the quantized transform coefficients for the target block based on the information on the quantized transform coefficients for the target block. The information on the quantized transform coefficients for the target block may be included in a sequence parameter set (SPS) or a slice header and may include at least one of information on whether a reduced transform (RST) is applied, information on a reduced factor, information on a minimum transform size to which the RST is applied, information on a maximum transform size to which the RST is applied, information on a reduced inverse transform size, and information on a transform index indicating any one of transform kernel matrices included in a transform set.

The decoding apparatus 300 according to an embodiment may derive transform coefficients by dequantizing the quantized transform coefficients for the target block (S1120).

The derived transform coefficients may be arranged in 4×4 blocks according to an inverse diagonal scanning order, and transform coefficients in a 4×4 block may also be arranged according to the inverse diagonal scanning order. That is, the dequantized transform coefficients may be disposed according to the inverse scanning order applied in video codec, such as VVC or HEVC.

The decoding apparatus 300 according to an embodiment may derive modified transform coefficients based on an inverse reduced secondary transform (RST) of the transform coefficients (S1130).

In an example, the inverse RST may be performed based on an inverse RST transform matrix, and the inverse RST transform matrix may be a nonsquare matrix in which the number of columns is less than the number of rows.

In an embodiment, S1130 may include decoding a transform index, determining whether a condition for applying an inverse RST is satisfied based on the transform index, selecting a transform kernel matrix, and applying the inverse RST to the transform coefficients based on the selected transform kernel matrix and/or the reduced factor when the condition for applying the inverse RST is satisfied. In this case, the size of an inverse RST matrix may be determined based on the reduced factor.

The decoding apparatus 300 according to an embodiment may derive residual samples for the target block based on an inverse transform of the modified transform coefficients (S1140).

The decoding apparatus 300 may perform an inverse primary transform on the modified transform coefficients for the target block, in which case a reduced inverse transform may be applied or a conventional separable transform may be used as the inverse primary transform.

The decoding apparatus 300 according to an embodiment may generate reconstructed samples based on the residual samples for the target block and prediction samples for the target block (S1150).

Referring to S1130, it may be identified that the residual samples for the target block are derived based on the inverse RST of the transform coefficients for the target block. From the perspective of the size of the inverse transform matrix, since the size of a regular inverse transform matrix is N×N but the size of the inverse RST matrix is reduced to N×R, it is possible to reduce memory usage in a case of performing the inverse RST by an R/N ratio compared to that in a case of performing a regular transform. Further, using the inverse RST matrix can reduce the number of multiplications (N×R) by the R/N ratio, compared to the number of multiplications N×N in a case of using the regular inverse transform matrix. In addition, since only R transform coefficients need to be decoded when the inverse RST is applied, the total number of transform coefficients for the target block may be reduced from N to R, compared to that in a case where N transform coefficients needs to be decoded when a regular inverse transform is applied, thus increasing decoding efficiency. That is, according to S1130, the (inverse) transform efficiency and decoding efficiency of the decoding apparatus 300 may be increased through the inverse RST.

FIG. 12 is a control flowchart illustrating an image decoding method by a decoding apparatus according to an embodiment of the present disclosure. A method for transforming an image, specifically a secondary transform process, performed by the decoding apparatus or an inverse secondary transform corresponding to a secondary transform performed by an encoding apparatus is described with reference to FIG. 12. Hereinafter, an inverse secondary transform performed by the decoding apparatus is referred to as a non-separable secondary transform.

The decoding apparatus 300 receives information on quantized transform coefficients, an intra prediction mode, and a transform index for a non-separable secondary transform through a bitstream (S1200).

According to an embodiment, the non-separable secondary transform is a non-separable transform of transforming coefficients without separating the coefficients in a specific direction, unlike a primary transform of vertically or horizontally separating coefficients to be transformed and transforming the coefficients. The non-separable transform may be a low-frequency non-separable transform of transforming only a low-frequency region rather than an entire target block to be transformed.

The decoding apparatus 300 further receives flag information indicating whether a transform index exists through the bitstream.

The flag information indicating whether the transform index is received may be sps_st_enabled_flag in Table 41, which may be modified to sps_lfnst_enabled_flag according to the type of a secondary transform. The flag information may indicate whether the transform index is received, that is, whether the transform index exists in the bitstream, and may be received via the syntax of a sequence parameter.

When the flag information is 0, no transform index exists, and thus the non-separable secondary transform may not be performed. When the flag information is 1, the transform index exists, and thus the transform index may be received and parsed by the decoding apparatus.

The transform index may exist in the syntax of a coding unit.

A syntax element of the transform index according to an embodiment may indicate whether the non-separable secondary transform is applied and any one of transform kernel matrices included in a transform set. When the transform set includes two transform kernel matrices, the syntax element of the conversion index may have three values.

That is, according to an embodiment, the value of the syntax element of the transform index may include 0 indicating that the non-separable secondary transform is not applied to the target block, 1 indicating a first transform kernel matrix of the transform kernel matrices, and 2 indicating a second transform kernel matrix of the transform kernel matrices. This information is received as syntax information, and the syntax information is received as a binarized bin string including a 0 and a 1.

In this case, the three values of the syntax element of the transform index may be coded into 0, 10, and 11, respectively, according to truncated unary coding. That is, the value of the syntax element of 0 may be binarized into ‘0’, the value of the syntax element of 1 may be binarized into ‘10’, and the value of the syntax element of 2 may be binarized into ‘11’.

According to an embodiment, different pieces of context information, that is, different probability models, may be applied to two bins of the transform index, respectively. That is, all of the two bins of the transform index may be decoded by a context method rather than by a bypass method, wherein a first bin of the bins of the syntax element of the transform index may be decoded based on first context information, and a second bin of the bins of the syntax element of the transform index may be decoded based on second context information.

Transform coefficients may be derived from the quantized transform coefficients received through the bitstream via dequantization as shown in S1120 of FIG. 11 (S1210). The following transform coefficients refer to the dequantized transform coefficients.

When the received transform index does not indicate that the non-separable secondary transform is not performed, that is, when the transform index is not 0, the decoding apparatus may derive an input transform coefficient size indicating the length of the dequantized transform coefficient to which the non-separable secondary transform is applied, an output transform coefficient size indicating the length of a modified transform coefficient to which the non-separable secondary transform is applied, and a transform set mapped to an intra mode for the target block. Here, when the target block is partitioned into a predetermined number of subblocks and the subblocks are coded by intra prediction, the decoding apparatus derives modified transform coefficients in subblocks by applying one transform kernel matrix to the subblocks (S1220).

That is, according to an embodiment of the present disclosure, in the non-separable secondary transform, the same transform kernel matrix may be applied to the subblocks, and a transform index indicating the transform kernel matrix may be signaled once for the plurality of subblocks. This transform index may be signaled in units of the target block partitioned into the subblocks, and the target block may be a coding unit. The coding unit is a concept including a coding block partitioned into subblocks. When the target block is regarded as a coding unit, a subblock on which the non-separable secondary transform is individually performed may be regarded as a transform unit or transform block, which is a unit of transform.

The decoding apparatus may derive whether the target block is partitioned into the predetermined number of subblocks by receiving and parsing flag information indicating whether to apply ISP coding or an ISP mode. Further, the decoding apparatus may derive the size and number of the partitioned subblocks through flag information indicating a direction in which the target block is partitioned. For example, as shown in FIG. 9, when the size (width×height) of the target block is 8×4, the target block may be vertically partitioned into two subblocks, and the non-separable secondary transform may be performed on each of the two subblocks. When the size (width×height) of the target block is 4×8, the target block may be horizontally partitioned into two subblocks, and the non-separable secondary transform may be performed on each of the two subblocks. Alternatively, as shown in FIG. 10, when the size (width×height) of the target block is greater than 4×8 or 8×4, that is, when the size of the target block is 1) 4×N or N×4 (N≥16), or 2) M×N (M≥8, N≥8), the target block may be horizontally or vertically partitioned into four subblocks.

According to another embodiment of the present disclosure, when a certain condition is not satisfied, ISP coding of partition into subblocks may not be applied, and different transform kernel matrices may be applied to subblocks partitioned by the ISP mode.

The non-separable secondary transform applied to the subblocks is described in detail as follows.

The size of an input transform coefficient refers to the length of transform coefficients, that is, the number of transform coefficients, which are subjected to an matrix operation with a transform kernel matrix, and the size of an output transform coefficient refers to the length of modified transform coefficients, that is, the number of modified transform coefficients, output after the matrix operation is performed.

According to an example, when the size of the subblock is 4×4 or 8×8, the size of the input transform coefficient may be 8, and when the size of the subblock is not 4×4 or 8×8, the size of the input transform coefficient may be 16. That is, when the size of the subblock, that is, the transform block, is 4×4, eight transform coefficients arranged in a scanning order from a top-left position of the 4×4 block are input data, and when the size of the transform block is 8×8, only eight transform coefficients arranged in the scanning order from a top-left position of the 8×8 block are input data. In cases other than these two cases, that is, 1) when the subblock is 4×N or N×4 (N≥8), or 2) when both the width and height of the subblock are equal to or greater than 8 (8 or greater) and the width or height is greater than 8, 16 transform coefficients are input for a matrix operation.

According to an example, when the width and height of the subblock are 8 or greater, the size of the output transform coefficient may be 48, and when the width or height of the subblock is less than 8, the size of the output transform coefficient may be 16.

For example, when the width and height of the transform block are 8 or greater, inverse RST 8×8 is applied. That is, the non-separable secondary transform may be applied to up to a top-left 4×4 region of a top-left 8×8 region of the transform block, and 48 modified transform coefficients may be derived in top-left, top-right, and bottom-left 4×4 regions excluding a bottom-right 4×4 region rather than in the entire 8×8 region as a result of the non-separable secondary transform. However, when the width or height of the subblock is less than 8, for example, in a case of a 4×4, 4×8, or 8×4 transform block, inverse RST 4×4 is applied to a top-left 4×4 region of the transform block. That is, the non-separable secondary transform may be applied to 8 or 16 transform coefficients arranged according to the scanning order from a top-left position of the 4×4 region, and 16 modified transform coefficients may be derived in the 4×4 region as a result of the non-separable secondary transform.

The transform set may be derived by a mapping relationship according to the intra prediction mode for the subblock, and one transform set may be mapped to a plurality of intra prediction modes. For example, there may be four transform sets according to the intra prediction mode.

When the input data for the non-separable secondary transform is derived, the decoding apparatus may derive a transform kernel matrix based on the size of the output transform coefficient, the transform set, and the transform index.

Each one transform set may include a plurality of transform kernel matrices. The transform index may indicate any one of the plurality of transform kernel matrices. For example, when one transform set includes two transform kernel matrices, the transform index may indicate any one of the two transform kernel matrices.

The transform kernel matrix may be determined based on the number of modified transform coefficients, information on the transform set, and the value of the transform index.

As shown in Table 8, Table 9, Table 14, and Table 18 to Table 20, the size of the transform kernel matrix and the selected matrix itself may change depending on the type of the non-separable secondary transform (RST 8×8 or RST 4×4) applied to a block having a predetermined size in the subblock and the number of output modified transform coefficients.

According to an example, the transform kernel matrix may be applied to a specific region, for example, an 8×8 region or a 4×4 region, at the top-left of the subblock according to the reduced or simplified size of the secondary transform, and the size of the modified transform coefficients, that is, the number of the transform coefficients, output by applying the transform kernel matrix may be derived based on the transform index, the intra prediction mode, and the size of the subblock to which the non-separable secondary transform is applied.

According to an example, when the non-separable secondary transform is applied to transform coefficients in a region, that is, an 8×8 region or a 4×4 region, of the subblock, the non-separable secondary transform may be applied to only some of the transform coefficients included in the 8×8 region or the 4×4 region. When only 48 transform coefficients among the transform coefficients in the 8×8 region are output for the non-separable secondary transform, a 64×m transform kernel matrix applied to the 8×8 region may be further reduced to a 48×m transform kernel matrix. Alternatively, when only eight transform coefficients among the transform coefficients in the 4×4 region are input for the non-separable secondary transform, a transform kernel matrix applied to the 4×4 region is a 16×8 matrix.

According to an example, m may be 16, and the 48×16 transform kernel matrix may be a transform kernel matrix based on Table 14, that is, the transposed matrix of the matrix of Table 14. Alternatively, according to an example, the 16×8 transform kernel matrix may be a transform kernel matrix based on Table 18. A 16×8 transform kernel matrix including only eight columns from the left in a 16×16 matrix obtained by transposing the matrix of Table 18 may be applied. Alternatively, a 48×8 matrix including only eight columns from the left in a 48×16 matrix obtained by transposing the matrix of Table 14 may be applied.

In summary, when the size of the input transform coefficients is 8 and the size of the output transform coefficients is 16, a matrix including eight columns extracted from a preset 16×16 transform kernel matrix may be used for the matrix operation. When the size of the input transform coefficient is 16 and the size of the output transform coefficient is 16, the preset 16×16 transform kernel matrix may be used for the matrix operation. When the size of the input transform coefficient is 16 and the size of the output transform coefficient is 48, a preset 48×16 transform kernel matrix may be used for the matrix operation. When the size of the input transform coefficient is 8 and the size of the output transform coefficient is 48, a matrix including eight columns extracted from the preset 48×16 transform kernel matrix may be used for the matrix operation.

There may be four transform sets, and two transform kernel matrices may be included in each transform set. In this case, the transform index may have a value of 0 indicating that the secondary is not applied and a value of 1 or 2 indicating one of the two transform kernel matrices.

The decoding apparatus may derive the modified transform coefficients based on the matrix operation of the transform kernel matrix and a transform coefficient list corresponding to the size of the input transform coefficient.

The transform coefficient list may include dequantized transform coefficients that are read according to the forward diagonal scanning order of the subblock.

The modified transform coefficients in a two-dimensional array may be derived through the matrix operation of a one-dimensional array of the transform coefficients derived through the dequantization, that is, the transform coefficient list, and the transform kernel matrix as shown in Equation 7.

According to this embodiment, the inverse transformer 322 may apply the transform kernel matrix to transform coefficients in the top-left 4×4 region of the 8×8 region of the subblock, thereby deriving the modified transform coefficients in the top-left 4×4 region, the top-right 4×4 region, and the bottom-left 4×4 region of the 8×8 region.

According to an example, when performing the matrix operation of the transform coefficients in the top-left 4×4 region of the 8×8 region and the transform kernel matrix, the transform coefficients in the top-left 4×4 region of the 8×8 region may be one-dimensionally arranged according to the forward diagonal scanning order as shown in Table 16, and after the matrix operation with the transform kernel matrix, the transform coefficients in the one-dimensional array may be two-dimensionally arranged in the top-left 4×4 region, the top-right 4×4 region, and the bottom-left 4×4 region of the 8×8 region according to either the row-first order or the column-first order according to the intra prediction mode applied to the subblock as shown in Table 15 or Table 17. That is, an inverse secondary transform may be applied to 16 transform coefficients in the top-left 4×4 region of the 8×8 region, and 48 modified transform coefficients in the top-left 4×4 region, the top-right 4×4 region, and the bottom-left 4×4 region of the 8×8 region may be derived through the operation with the transform kernel matrix.

According to an embodiment, the inverse transformer 322 may apply the transform kernel matrix to some transform coefficients in a 4×4 region to which a forward LFNST is applied in the subblock, for example, up to eight transform coefficients from the top-left position of the 4×4 region according to the scanning order, thereby deriving 16 modified transform coefficients in the 4×4 region. Hereinafter, a region in which the eight transform coefficients are arranged is referred to as a top-left region in the 4×4 region.

As described above, when either the height or the width of the subblock to which the transform is applied is less than 8, a non-separable secondary transform with a transform matrix having a reduced size may be applied, for example, to a 4×4 transform block, an upper 4×4 block of a 4×8 transform block, or a left 4×4 block of a 8×4 transform block.

According to an example, when performing the matrix operation of the transform coefficients in the top-left region of the 4×4 region and the transform kernel matrix, the eight transform coefficients in the top-left region of the 4×4 region may be one-dimensionally arranged according to the forward diagonal scanning order, and after the matrix operation with the transform kernel matrix, the transform coefficients in the one-dimensional array may be two-dimensionally arranged in the 4×4 region according to either the row-first order or the column-first order according to the intra prediction mode applied to the subblock as shown in Table 12 or Table 13. That is, an inverse secondary transform may be applied to the eight transform coefficients in the 4×4 region, and 16 modified transform coefficients in the 4×4 region may be derived through the operation with the transform kernel matrix.

When an intra prediction mode applicable to the subblock is any one of 65 directional modes, intra prediction modes are symmetric with respect to intra prediction mode 34 in a top-left diagonal direction, and the intra prediction mode applied to the subblock includes modes 2 to 34 in a left direction based on intra prediction mode 34, the modified transform coefficients may be two-dimensionally arranged according to the row-first order.

When the intra prediction mode applied to the subblock includes modes 35 to 66 in a right direction based on intra prediction mode 34, the modified transform coefficients may be two-dimensionally arranged according to the column-first order.

When the intra prediction mode applied to the subblock is a planar mode or a DC mode, the modified transform coefficients may be two-dimensionally arranged according to the row-first order.

The inverse transformer 322 may apply the non-separable secondary transform, thereby generating the modified transform coefficients in the 8×8 region, specifically the 8×8 region excluding the bottom-right 4×4 region of the 8×8 region, or in the 4×4 region as a two-dimensional block.

The decoding apparatus may derive residual samples for the target block based on an inverse primary transform on the modified transform coefficients (S1230).

According to an embodiment of the present disclosure, the inverse primary transform may be based on a multiple transform selection (MTS). A multiple core transform, in which a multiple transform is applied as a primary transform, may refer to a transform method additionally using discrete cosine transform (DCT) type 2, discrete sine transform (DST) type 7, DCT type 8, and/or DST type 1. According to the inverse primary transform, the modified transform coefficients in a frequency domain are transformed into a residual signal in a space domain.

The following drawings are provided to describe specific examples of the present disclosure. Since the specific designations of devices or the designations of specific signals/messages/fields illustrated in the drawings are provided for illustration, technical features of the present disclosure are not limited to specific designations used in the following drawings.

FIG. 13 is a flowchart illustrating an operation of a video encoding apparatus according to an embodiment of the present disclosure.

Each operation illustrated in FIG. 13 may be performed by the encoding apparatus 200 illustrated in FIG. 2. Specifically, S1310 may be performed by the predictor illustrated in FIG. 2, S1320 may be performed by the subtractor 231 illustrated in FIGS. 2, S1330 and S1340 may be performed by the transformer 232 illustrated in FIG. 2, and S1350 may be performed by the quantizer 233 and the entropy encoder 240 illustrated in FIG. 2. Operations according to S1310 to S1350 are based on some of contents described in FIG. 4 to FIG. 10. Therefore, a description of specific details overlapping with those explained above with reference to FIG. 4 to FIG. 10 will be omitted or will be made briefly.

The encoding apparatus 200 according to an embodiment may derive prediction samples based on an intra prediction mode applied to a target block (S1310).

The encoding apparatus 200 according to an embodiment may derive residual samples for the target block (S1320).

The encoding apparatus 200 according to an embodiment may derive transform coefficients for the target block based on primary transform of the residual samples (S1330). The primary transform may be performed through a plurality of transform kernels, and the transform kernels may be selected based on the intra prediction mode.

The decoding apparatus 300 may perform a secondary transform, specifically an NSST, on the transform coefficients for the target block, in which case the NSST may be performed based on a reduced transform (RST) or without being based on the RST. When the NSST is performed based on the reduced transform, an operation according to S1340 may be performed.

The encoding apparatus 200 according to an embodiment may derive modified transform coefficients for the target block based on the RST of the transform coefficients (S1340). In an example, the RST may be performed based on a reduced transform matrix or a transform kernel matrix, and the reduced transform matrix may be a nonsquare matrix in which the number of rows is less than the number of columns.

In an embodiment, S1340 may include determining whether a condition for applying the RST is satisfied, generating and encoding the transform index based on the determination, selecting a transform kernel, and applying the RST to the residual samples based on the selected transform kernel matrix and/or a reduced factor when the condition for applying the RST is satisfied. In this case, the size of the reduced transform kernel matrix may be determined based on the reduced factor.

The encoding apparatus 200 according to an embodiment may derive quantized transform coefficients by performing quantization based on the modified transform coefficients for the target block and may encode information on the quantized transform coefficients (S1350).

Specifically, the encoding apparatus 200 may generate the information on the quantized transform coefficients and may encode the generated information on the quantized transform coefficients.

In an example, the information on the quantized transform coefficients may include at least one of information on whether the RST is applied, information on the reduced factor, information on a minimum transform size to which the RST is applied, and information on a maximum transform size to which the RST is applied.

Referring to S1340, it may be identified that the transform coefficients for the target block are derived based on the RST of the residual samples. From the perspective of the size of the transform kernel matrix, since the size of a regular transform kernel matrix is N×N but the size of the reduced transform matrix is reduced to R×N, it is possible to reduce memory usage in a case of performing the RST by an R/N ratio compared to that in a case of performing a regular transform. Further, using the reduced transform kernel matrix can reduce the number of multiplications (R×N) by the R/N ratio, compared to the number of multiplications N×N in a case of using the regular transform kernel matrix. In addition, since only R transform coefficients are derived when the RST is applied, the total number of transform coefficients for the target block may be reduced from N to R, compared to that in a case where N transform coefficients are derived when a regular transform is applied, thus reducing the amount of data transmitted by the encoding apparatus 200 to the decoding apparatus 300. That is, according to S1340, the transform efficiency and coding efficiency of the encoding apparatus 320 may be increased through the RST.

FIG. 14 is a control flowchart illustrating an image encoding method by an encoding apparatus according to an embodiment of the present disclosure. A method for transforming an image, specifically a secondary transform process, performed by the encoding apparatus or a secondary transform corresponding to an inverse secondary transform performed by a decoding apparatus is described with reference to FIG. 14. Hereinafter, a secondary transform performed by the encoding apparatus is referred to as a non-separable secondary transform.

According to an embodiment, the non-separable secondary transform is a non-separable transform of transforming coefficients without separating the coefficients in a specific direction, unlike a primary transform of vertically or horizontally separating coefficients to be transformed and transforming the coefficients. The non-separable transform may be a low-frequency non-separable transform (LFNST) of transforming only a low-frequency region rather than an entire target block to be transformed.

First, the encoding apparatus 200 derives transform coefficients by applying a primary transform to residual samples for a target block (S1400).

When a non-separable secondary transform is applied to the transform coefficients derived through the primary transform, if the target block is a coding block that is partitioned into a predetermined number of subblocks and is subjected to intra prediction, the encoding apparatus may derive modified transform coefficients in subblocks by applying one transform kernel matrix to the subblocks (S1410).

That is, according to an embodiment of the present disclosure, the same transform kernel matrix may be applied to the plurality of subblocks in the non-separable secondary transform, and the non-separable secondary transform may be performed by a unit of an individual subblock. Applying the same transform kernel matrix to the plurality of subblocks means that one transform kernel matrix is applied by a unit of the target block that is partitioned into subblocks. Here, when the target block is regarded as the coding unit, a subblock on which the non-separable secondary transform is individually performed may be regarded as a transform unit or transform block, which is a unit of transform.

The encoding apparatus may derive a direction in which the target block is partitioned and the size and number of the partitioned subblocks. For example, as shown in FIG. 9, when the size (width×height) of the target block is 8×4, the target block may be vertically partitioned into two subblocks, and the non-separable secondary transform may be performed on each of the two subblocks. When the size (width×height) of the target block is 4×8, the target block may be horizontally partitioned into two subblocks, and the non-separable secondary transform may be performed on each of the two subblocks. Alternatively, as shown in FIG. 10, when the size (width×height) of the target block is greater than 4×8 or 8×4, that is, when the size of the target block is 1) 4×N or N×4 (N≥16), or 2) M×N (M≥8, N≥8), the target block may be horizontally or vertically partitioned into four subblocks

According to another embodiment of the present disclosure, when a certain condition is not satisfied, ISP coding of partition into subblocks may not be applied, and different transform kernel matrices may be applied to subblocks partitioned by the ISP mode.

Hereinafter, the non-separable secondary transform applied to the subblocks is described in detail as follows.

The encoding apparatus may derive the size of an input transform coefficient, the size of an output transform coefficient and a transform set mapped to an intra prediction mode for the subblock. The size of the input transform coefficient refers to the length of transform coefficients, that is, the number of transform coefficients, which are subjected to an matrix operation with a transform kernel matrix, and the size of the output transform coefficient refers to the length of modified transform coefficients, that is, the number of modified transform coefficients, output after the matrix operation is performed.

According to an example, when the width and height of the subblock are 8 or greater, the size of the input transform coefficient may be 48, and when the width or height of the subblock is less than 8, the size of the input transform coefficient may be 16.

For example, when the width and height of the transform block are 8 or greater, RST 8×8 may be applied. Thus, the non-separable secondary transform may be applied to a top-left 8×8 region of the transform block, and 8 (e.g., an 8×8 transform block) or 16 (e.g., a transform block greater than 8×8) modified transform coefficients may be derived as a result of the non-separable secondary transform. However, when the width or height of the subblock is less than 8, for example, in a case of a 4×4, 4×8, or 8×4 transform block, RST 4×4 may be applied. Thus, the non-separable secondary transform may be applied to 16 transform coefficients in a top-left 4×4 region of the transform block, and 8 (e.g., a 4×4 transform block) or 16 (e.g., a 4×8 or 8×4 transform block) modified transform coefficients may be derived as a result.

According to an example, when the size of the subblock is 4×4 or 8×8, the size of the output transform coefficient may be 8, and when the size of the subblock is not 4×4 or 8×8, the size of the output transform coefficient may be 16. That is, when the size of the subblock, that is, the transform block, is 4×4, eight pieces of data are output after the non-separable secondary transform, and even when the size of the transform block is 8×8, only eight transform coefficients are output after the non-separable secondary transform. In cases other than these two cases, that is, 1) when both the width and the height are equal to or greater than 8 and at least one of the width the height is greater than 8, or 2) when the subblock is 4×N or N×4 (N≥8), 16 transform coefficients may output in each matrix operation.

The transform set may be derived by a mapping relationship according to the intra prediction mode for the subblock, and one transform set may be mapped to a plurality of intra prediction modes. For example, there may be four transform sets according to the intra prediction mode.

When the input data for the non-separable secondary transform is derived, the encoding apparatus may derive the modified transform coefficients based on a matrix operation of any one of transform kernel matrices included in the transform set and a transform coefficient corresponding to the size of the input transform coefficient.

The transformer 232 of the encoding apparatus may select any one of a plurality of transform kernel matrices included in the transform set.

According to an embodiment, the transform set may be derived by the mapping relationship according to the intra prediction mode for the subblock, and one transform set may be mapped to a plurality of intra prediction modes. Further, each one transform set may include a plurality of transform kernel matrices. When one transform set includes two transform kernel matrices, a transform index indicating any one of the two transform kernel matrices may be encoded and signaled to a decoding apparatus.

When two transform processes are applied to the residual samples, the residual samples may be referred to as transform coefficients after the primary transform, and may be referred to as modified transform coefficients after the primary transform and then the non-separable secondary transform.

Each one transform set may include a plurality of transform kernel matrices. The transform index may indicate any one of the plurality of transform kernel matrices. For example, when one transform set includes two transform kernel matrices, the transform index may indicate any one of the two transform kernel matrices.

The transform kernel matrix may be determined based on the number of modified transform coefficients, information on the transform set, and the value of the transform index.

As shown in Table 8, Table 9, Table 14, and Table 18 to Table 20, the size of the transform kernel matrix and a matrix coefficient may change depending on the type of the non-separable secondary transform (RST 8×8 or RST 4×4) applied to a block having a predetermined size in the subblock and the number of output modified transform coefficients.

According to an example, the transform kernel matrix may be applied to a specific region, for example, an 8×8 region, specifically the 8×8 region excluding a bottom-right 4×4 region of the 8×8 region, or a 4×4 region, at the top-left of the subblock according to the reduced or simplified size of the secondary transform, and the size of the modified transform coefficients, that is, the number of the transform coefficients, output by applying the transform kernel matrix may be derived based on the transform index, the intra prediction mode, and the size of the subblock to which the non-separable secondary transform is applied.

According to an example, when the non-separable secondary transform is applied to transform coefficients in a region, that is, an 8×8 region or a 4×4 region, of the subblock, the non-separable secondary transform may be applied to only some of the transform coefficients included in the 8×8 region or the 4×4 region. When only 48 transform coefficients among the transform coefficients in the 8×8 region are input for the secondary transform, an m×64 transform kernel matrix applied to the 8×8 region may be further reduced to an m×48 transform kernel matrix. Alternatively, when only eight transform coefficients among the transform coefficients in the 4×4 region are output by applying the non-separable secondary transform, a transform kernel matrix applied to the 4×4 region is an 8×16 matrix.

According to an example, m may be 16, and a 16×48 transform kernel matrix may be a transform kernel matrix illustrated in Table 14. Alternatively, according to an example, an 8×16 transform kernel matrix may be a transform kernel matrix based on Table 18. That is, when m transform coefficients are generated by applying the secondary transform to a 4×4 region, an m×16 transform kernel matrix may be applied to the 4×4 region. According to an example, m may be 8, and an 8×16 transform kernel matrix may be a matrix including top eight rows in Table 18. Alternatively, according to an example, an 8×48 transform kernel matrix may be a transform kernel matrix based on Table 14. That is, when m transform coefficients are generated by applying the secondary transform to an 8×8 region excluding the bottom-right 4×4 region, an m×48 transform kernel matrix may be applied to the 8×8 region excluding the bottom-right 4×4 region. According to an example, m may be 8, and an 8×48 transform kernel matrix may be a matrix including top eight rows in Table 14.

In summary, when the size of the input transform coefficients is 16 and the size of the output transform coefficients is 8, a matrix including eight rows extracted from a preset 16×16 transform kernel matrix may be used for the matrix operation. When the size of the input transform coefficient is 16 and the size of the output transform coefficient is 16, the preset 16×16 transform kernel matrix may be used for the matrix operation. When the size of the input transform coefficient is 48 and the size of the output transform coefficient is 16, a preset 16×48 transform kernel matrix may be used for the matrix operation. When the size of the input transform coefficient is 48 and the size of the output transform coefficient is 8, a matrix including eight rows extracted from the preset 16×48 transform kernel matrix may be used for the matrix operation.

There may be four transform sets, and two transform kernel matrices may be included in each transform set. In this case, the transform index may have a value of 0 indicating that the secondary is not applied and a value of 1 or 2 indicating one of the two transform kernel matrices.

When performing the non-separable secondary transform on the transform coefficients using the transform kernel matrix, the transformer 232 may one-dimensionally arrange the transform coefficients in a two-dimensional array via the primary transform according to either a row-first order or a column-first order based on the intra prediction mode applied to the subblock.

Specifically, according to an embodiment, the transformer 232 may apply the transform kernel matrix to transform coefficients in the top-left 4×4 region, the top-right 4×4 region, and the bottom-left 4×4 region of the 8×8 region of the subblock, thereby deriving modified transform coefficients corresponding to the top-left 4×4 region of the 8×8 region.

The transform kernel matrix may be applied to a specific region at the top-left of the sub-block, for example, an 8×8 region, a 4×4 region, or a portion of the 8×8 region, depending on the reduced or simplified size of the secondary transform, and the size of modified transform coefficients, that is, the number of modified transform coefficients, output by applying the transform kernel matrix may be derived based on the size of the transform kernel matrix, the intra prediction mode, and the size of the subblock to which the secondary transform is applied.

As shown in Equation 5, the two-dimensional transform coefficients need to be arranged in one dimension for the matrix operation with the transform kernel matrix, and a smaller number of modified transform coefficients than the number of transform coefficients may be derived through the operation illustrated in Equation 6.

That is, the transform coefficients in a two-dimensional array in the specific region may be read in one dimension according to a certain order, and the modified transform coefficients are derived therefrom through the matrix operation with the transform kernel matrix.

According to an example, when performing the matrix operation of the transform kernel matrix for the 8×8 region, the 48 transform coefficients in the top-left 4×4 region, the top-right 4×4 region, and the bottom-left 4×4 region of the 8×8 region may be one-dimensionally arranged according to either the row-first order or the column-first order according to the intra prediction mode applied to the subblock as shown in Table 15 or Table 18, and the derived 16 modified transform coefficients may be arranged in a diagonal scanning direction in the top-left 4×4 region of the 8×8 region as shown in Table 16.

As described above, the transformer 232 may apply the transform kernel matrix to 16 transform coefficients in the 4×4 subblock, thereby deriving eight modified transform coefficients corresponding to a top-left region of the 4×4 region. That is, the 16 transform coefficients in the 4×4 region to be transformed may be one-dimensionally arranged in either a row-first direction or a column-first direction according to the intra prediction mode applied to the subblock as shown in Table 12 or Table 13, and the derived eight modified transform coefficients may be arranged in the diagonal scanning direction in the top-left region of the 4×4 region.

When an intra prediction mode applicable to the subblock is any one of 65 directional modes, intra prediction modes are symmetric with respect to intra prediction mode 34 in a top-left diagonal direction, and the intra prediction mode applied to the subblock includes modes 2 to 34 in a left direction based on intra prediction mode 34, the transform coefficients in the top-left 4×4 region, the top-right 4×4 region, and the bottom-left 4×4 region of the 8×8 region may be one-dimensionally arranged according to the row-first order as shown in Table 15.

When the intra prediction mode applied to the subblock includes modes 35 to 66 in a right direction based on intra prediction mode 34, the transform coefficients in the top-left 4×4 region, the top-right 4×4 region, and the bottom-left 4×4 region of the 8×8 region may be one-dimensionally arranged according to the column-first order as shown in Table 17.

When the intra prediction mode applied to the subblock is a planar mode or a DC mode, the transform coefficients in the top-left 4×4 region, the top-right 4×4 region, and the bottom-left 4×4 region of the 8×8 region may be one-dimensionally arranged according to the row-first order.

When the non-separable secondary transform is performed, the entropy encoder 240 may derive quantized transform coefficients by performing quantization based on the modified transform coefficients (S1420), may encode the transform index in coding units, and may encode information on the quantized transform coefficients and the quantized transform coefficients (S1430).

First, the entropy encoder 240 may derive a syntax element value for the transform index indicating any one of the transform kernel matrices included in the transform set, may binarize the derived syntax element value for the transform index, and may encode bins of a syntax element bin string based on context information, that is, a context model, on a bin string of the transform index.

The transform index indicating the transform kernel matrix may be encoded once for the plurality of subblocks. That is, the transform index may be encoded and output by a unit of the target block that is partitioned into the subblocks, and the target block may be a coding unit. The coding unit is a concept including a coding block partitioned into subblocks.

The encoding apparatus may encode flag information indicating whether to apply ISP coding or an ISP mode, and may also encode and output flag information indicating a direction in which the target block is partitioned.

The encoded bin string of the syntax element may be output as a bitstream to the decoding apparatus 300 or to the outside.

In the above-described embodiments, the methods are explained on the basis of flowcharts by means of a series of steps or blocks, but the present disclosure is not limited to the order of steps, and a certain step may be performed in order or step different from that described above, or concurrently with another step. Further, it may be understood by a person having ordinary skill in the art that the steps shown in a flowchart are not exclusive, and that another step may be incorporated or one or more steps of the flowchart may be removed without affecting the scope of the present disclosure.

The above-described methods according to the present disclosure may be implemented as a software form, and an encoding apparatus and/or decoding apparatus according to the disclosure may be included in a device for image processing, such as, a TV, a computer, a smartphone, a set-top box, a display device or the like.

When embodiments in the present disclosure are embodied by software, the above-described methods may be embodied as modules (processes, functions or the like) to perform the above-described functions. The modules may be stored in a memory and may be executed by a processor. The memory may be inside or outside the processor and may be connected to the processor in various well-known manners. The processor may include an application-specific integrated circuit (ASIC), other chipset, logic circuit, and/or a data processing device. The memory may include a read-only memory (ROM), a random access memory (RAM), a flash memory, a memory card, a storage medium, and/or other storage device. That is, embodiments described in the present disclosure may be embodied and performed on a processor, a microprocessor, a controller or a chip. For example, function units shown in each drawing may be embodied and performed on a computer, a processor, a microprocessor, a controller or a chip.

Further, the decoding apparatus and the encoding apparatus to which the present disclosure is applied, may be included in a multimedia broadcasting transceiver, a mobile communication terminal, a home cinema video device, a digital cinema video device, a surveillance camera, a video chat device, a real time communication device such as video communication, a mobile streaming device, a storage medium, a camcorder, a video-on-demand (VoD) service providing device, an over the top (OTT) video device, an Internet streaming service providing device, a three-dimensional (3D) video device, a video telephony video device, and a medical video device, and may be used to process a video signal or a data signal. For example, the over-the-top (OTT) video device may include a game console, a Blu-ray player, an Internet access TV, a Home theater system, a smartphone, a Tablet PC, a digital video recorder (DVR) and the like.

In addition, the processing method to which the present disclosure is applied, may be produced in the form of a program executed by a computer, and be stored in a computer-readable recording medium. Multimedia data having a data structure according to the present disclosure may also be stored in a computer-readable recording medium. The computer-readable recording medium includes all kinds of storage devices and distributed storage devices in which computer-readable data are stored. The computer-readable recording medium may include, for example, a Blu-ray Disc (BD), a universal serial bus (USB), a ROM, a PROM, an EPROM, an EEPROM, a RAM, a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device. Further, the computer-readable recording medium includes media embodied in the form of a carrier wave (for example, transmission over the Internet). In addition, a bitstream generated by the encoding method may be stored in a computer-readable recording medium or transmitted through a wired or wireless communication network. Additionally, the embodiments of the present disclosure may be embodied as a computer program product by program codes, and the program codes may be executed on a computer by the embodiments of the present disclosure. The program codes may be stored on a computer-readable carrier.

FIG. 15 illustrates the structure of a content streaming system to which the present disclosure is applied.

Further, the contents streaming system to which the present disclosure is applied may largely include an encoding server, a streaming server, a web server, a media storage, a user equipment, and a multimedia input device.

The encoding server functions to compress to digital data the contents input from the multimedia input devices, such as the smart phone, the camera, the camcorder and the like, to generate a bitstream, and to transmit it to the streaming server. As another example, in a case where the multimedia input device, such as, the smart phone, the camera, the camcorder or the like, directly generates a bitstream, the encoding server may be omitted. The bitstream may be generated by an encoding method or a bitstream generation method to which the present disclosure is applied. And the streaming server may store the bitstream temporarily during a process to transmit or receive the bitstream.

The streaming server transmits multimedia data to the user equipment on the basis of a user's request through the web server, which functions as an instrument that informs a user of what service there is. When the user requests a service which the user wants, the web server transfers the request to the streaming server, and the streaming server transmits multimedia data to the user. In this regard, the contents streaming system may include a separate control server, and in this case, the control server functions to control commands/responses between respective equipments in the content streaming system.

The streaming server may receive contents from the media storage and/or the encoding server. For example, in a case the contents are received from the encoding server, the contents may be received in real time. In this case, the streaming server may store the bitstream for a predetermined period of time to provide the streaming service smoothly.

For example, the user equipment may include a mobile phone, a smart phone, a laptop computer, a digital broadcasting terminal, a personal digital assistant (PDA), a portable multimedia player (PMP), a navigation, a slate PC, a tablet PC, an ultrabook, a wearable device (e.g., a watch-type terminal (smart watch), a glass-type terminal (smart glass), a head mounted display (HMD)), a digital TV, a desktop computer, a digital signage or the like. Each of servers in the contents streaming system may be operated as a distributed server, and in this case, data received by each server may be processed in a distributed manner.

Claims disclosed herein can be combined in a various way. For example, technical features of method claims of the present disclosure can be combined to be implemented or performed in an apparatus, and technical features of apparatus claims can be combined to be implemented or performed in a method. Further, technical features of method claims and apparatus claims can be combined to be implemented or performed in an apparatus, and technical features of method claims and apparatus claims can be combined to be implemented or performed in a method. 

What is claimed is:
 1. An image decoding method performed by a decoding apparatus, the method comprising: receiving quantized transform coefficients and a transform index for a non-separable secondary transform for a coding block; deriving transform coefficients by dequantizing the quantized transform coefficients; deriving modified transform coefficients based on a transform kernel matrix related to the transform index in a transform set; and deriving residual samples based on an inverse primary transform of the modified transform coefficients, wherein the coding block is partitioned into a plurality of sub-blocks based on an Intra Sub Partitions (ISP) mode including horizontal and vertical mode, wherein the coding block is partitioned into a specific number of sub-blocks based on a shape of a coding unit, wherein the transform index is signaled in unit of the coding block and applied to the plurality of sub-blocks, wherein the same transform kernel matrix is applied to the sub-blocks in the non-separable secondary transform, and wherein the modified transform coefficients are derived in unit of the sub-block.
 2. The image decoding method of claim 1, wherein each sub-block is a transform unit.
 3. The image decoding method of claim 1, wherein the coding block is partitioned into two sub: blocks when the coding block has a size (width x height) of 8×4, and wherein the coding block is partitioned into two sub: blocks when the coding block has a size (width x height) of 4×8.
 4. The image decoding method of claim 3, wherein the coding block is horizontally or vertically partitioned into four sub: blocks when the coding block has a size (width x height) greater than 4×8 or 8×4.
 5. An image encoding method performed by an image encoding apparatus, the method comprising: deriving prediction samples based on an intra prediction mode applied to a coding block; deriving residual samples for the coding block based on the prediction samples; deriving transform coefficients by applying a primary transform to the residual samples; deriving modified transform coefficients by performing a non-separable secondary transform on the transform coefficients using a transform set mapped to the intra prediction mode of the coding block and one transform kernel matrix comprised in the transform set; deriving quantized transform coefficients by performing quantization based on the modified transform coefficients; and encoding a transform index related to the transform kernel matrix and the quantized transform coefficients, wherein the coding block is partitioned into a plurality of sub-blocks based on an Intra Sub Partitions (ISP) mode including horizontal and vertical mode, wherein the coding block is partitioned into a specific number of sub-blocks based on a shape of a coding unit, wherein the transform index is encoded in a unit of the coding block and applied to the plurality of sub-blocks, wherein the same transform kernel matrix is applied to the sub-blocks in the non-separable secondary transform, and wherein the modified transform coefficients are derived in unit of sub-block.
 6. The image encoding method of claim 5, wherein the coding block is partitioned into two sub-blocks when the coding block has a size (width x height) of 8×4, and wherein the coding block is partitioned into two sub: blocks when the coding block has a size (width x height) of 4×8.
 7. The image encoding method of claim 5, wherein the coding block is horizontally or vertically partitioned into four sub: blocks when the coding block has a size (width x height) greater than 4×8 or 8×4.
 8. The image encoding method of claim 5, further comprising: encoding flag information indicating whether the ISP mode is applied to the coding block.
 9. A non-transitory computer-readable digital storage medium storing a bitstream generated by a method, the method comprising: deriving prediction samples based on an intra prediction mode applied to a coding block; deriving residual samples for the coding block based on the prediction samples; deriving transform coefficients by applying a primary transform to the residual samples; deriving modified transform coefficients by performing a non-separable secondary transform on the transform coefficients using a transform set mapped to the intra prediction mode of the coding block and one transform kernel matrix comprised in the transform set; deriving quantized transform coefficients by performing quantization based on the modified transform coefficients; and encoding image information including a transform index related to the transform kernel matrix and the quantized transform coefficients to generate the bitstream, wherein the coding block is partitioned into a plurality of sub-blocks based on an Intra Sub Partitions (ISP) mode including horizontal and vertical mode, wherein the coding block is partitioned into a specific number of sub: blocks based on a shape of a coding unit, wherein the transform index is encoded in a unit of the coding block and applied to the plurality of sub-blocks, wherein the same transform kernel matrix is applied to the sub-blocks in the non-separable secondary transform, and wherein the modified transform coefficients are derived in unit of sub-block. 